Reputation: 5067
When I dump an array in twig, it gives the following result:
array(1) {
[0]=>
object(TEST\Bundle\BlogBundle\Entity\Follow)#364 (3) {
["id":"TEST\Bundle\BlogBundle\Entity\Follow":private]=>
int(1)
["follower"]=>
int(2)
["followed"]=>
int(1)
}
}
int(1)
int(1)
How can I access the follower
parameter inside my loop which is:
{% for fol in followers %}
<pre> {{ dump(fol) }} </pre>
{% endfor %}
Thank you for your help.
Upvotes: 0
Views: 148
Reputation: 5877
Use TWIG attribute
docs. Example:
{% for fol in followers %}
<pre> {{ dump(attribute(fol[0], follower)) }} </pre>
{% endfor %}
Please make you sure that you have getters for follower
in TEST\Bundle\BlogBundle\Entity\Follow
or follower
attribute is public.
Or simillarly print value:
{% for fol in followers %}
<pre> {{ fol[0].follower }} </pre>
{% endfor %}
Upvotes: 1