Comments (6)
Check your entity: you are not returning a string in the __toString
method of your class which is invalid. It has nothing to do with any bundle but with your own code.
from sonataadminbundle.
Hi,
This is what I actually have in my entity :
MyEntity:
public function getSchemaType() {
// if($this->schemaType){
return $this->schemaType;
// }else{
// return 'none';
// }
}
SchemaTypes Entity:
public function __toString() {
return $this->schemaName;
}
If myEntity has a schemaType defined then the name is present in my Admin List otherwise the catchable fatal error is present.
The same thing happens for MyEntity that is nested and doesn't have a parent define ( I am trying to show the parent name in my list ).
One more thing, may this be important, if I uncomment the code above from getSchemaType() I get an error :
Item "id" for "none" does not exist in SonataAdminBundle:CRUD:list_orm_many_to_one.html.twig at line 16
Thank you for your time !
from sonataadminbundle.
__toString
fails because you return null
when the property is not initialized.
what is $this->schemaType
? The property mapped for the relation ? In this case, it is normal that it fails. An empty relation returns null
(as there is nothing for this relation), not 'none'
which is a PHP string.
from sonataadminbundle.
Yes it is the property mapped for the relation:
/**
* @Orm:ManyToOne(targetEntity="SchemaTypes")
* @Orm:JoinColumn(name="schematype_id", referencedColumnName="id")
*/
private $schemaType;
And the schemaName is the title of the SchemaType which I want it displayed.
Here is the code I have in my MyEntityAdmin class for the $list :
protected $list = array(
'title',
'schemaType',
//..
);
How can I avoid having these errors, considering that I want to display something custom like 'none' without/or with a custom url where no relation is present ?
Cheers,
Cezar
from sonataadminbundle.
don't return 'none'
in the getSchemaType()
method. Return it in __toString
when $this->schemaType
is null
from sonataadminbundle.
Thanks!
from sonataadminbundle.
Related Issues (20)
- Allow customize sonata-admin webpack build(s) HOT 1
- Rebuild template layer HOT 6
- Submitting a form with ->render instead of ->renderWithExtraParams does not work HOT 9
- Security threat within symfony/twig-bridge HOT 3
- SAML SSO and SCIM to the Admin Panel HOT 2
- Using SubClasses in admins create either not handable translation ids or urly urls HOT 2
- Overriding createQuery doesn't seem to be a thing anymore HOT 2
- symfony 7 compatibility HOT 1
- Problem 1 - symfony/security-acl[v3.1.0, ..., v3.1.2] require symfony/security-core ^3.4|^4.4|^5.0 -> found symfony/security-core[v3.4.0, ..., v3.4.49, v4.4.0, ..., v4.4.48, v5.0.0, ..., v5.4.30] but it conflicts with your root composer.json require (7.0.*). HOT 2
- Customise error message for ModelManagerException HOT 1
- CSRF token error occurs on record creation after applying symfony/security-http security patch HOT 4
- `Uncaught TypeError: __webpack_require__.O is not a function` after upgrading to a version >=4.24.0 HOT 8
- List add item using inline form
- The name "Doctrine\ODM\MongoDB\ArrayCollectionelements" contains illegal characters. HOT 2
- Input value "filters" contains a non-scalar value. HOT 1
- Incorrect Generic Typing for ModelManagerInterface HOT 1
- Batch actions `all_elements` on `SimplePager` HOT 1
- Incoherent batch behavior when performing batch all_elements and specifying id's at the same time HOT 2
- navbar_title missing for list view HOT 3
- status of runroom sortable behavior HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sonataadminbundle.