If this is a BUG REPORT:
In easyadmin, on my list view, i couldn't open the form of a associated object item, which shoot me an error as below:
filename : javiereguiluzeasyadmin-bundlesrcResourcesviewsdefaultfield_association.html.twig (line 11)
{% for item in value|slice(0, easyadmin_config('show.max_results')) %}
<li>
{% if link_parameters is defined %}
{# the empty string concatenation is needed when the primary key is an object (e.g. an Uuid object) #}
{% set primary_key_value = '' ~ attribute(item, link_parameters.primary_key_name) %}
<a href="{{ path('easyadmin', link_parameters|merge({ id: primary_key_value, referer: '' })) }}">{{ item }}</a>
{% else %}
{{ item }}
{% endif %}
</li>
{% endfor %}
I have added this function my entity,
class Pret{
public function __toString() {
return (string)$this->getProject();
return (string)$this->getPorter();
}
}
But, the error exist, What did i missed?
Probably whatever value is in {{ item }} is an Entity or some other object.
Since Twig 2.3 you can add the method __toString() into any unprintable class (including entities) and it will magically print the output of that function.
Add this to whatever object is causing the problem (ideally, you should add it to all your entities).
public function __toString() { return $this->getId(); /* or whatever you want */ }
thanks alot!
Closing as solved :)
Most helpful comment
Probably whatever value is in
{{ item }}is an Entity or some other object.Since Twig 2.3 you can add the method
__toString()into any unprintable class (including entities) and it will magically print the output of that function.Add this to whatever object is causing the problem (ideally, you should add it to all your entities).
public function __toString() { return $this->getId(); /* or whatever you want */ }