I trying to output an array from the database to the screen. In my entity:
/**
* @ORM\Column(type="array", nullable=true)
*/
private $category;
In my twig template:
{% for category in user.profile.category %}
{{ category }}
{% endfor %}
Error: Array to string conversion in ...
Where is my mistake?
So, as error shows you are trying convert array (in category
variable) to string. You can preview array by dump()
(doc.). In your case:
{% for category in user.profile.category %}
{{ dump(category) }}
{% endfor %}
Please notice that dump()
should be use only for debugging.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With