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?
TWIG doesn't know how you want to display your table.
By the way, you should consider naming your variable $categories
instead of $category
, as you table contains several categories.
Then try this:
{% for category in user.profile.categories %}
{{ category }}
{% endfor %}
If my answer doesn't help, please give us the structure of your array (is there any keys or sub-arrays in you table or is it just a list?)