I'm currently working on a cms using symfony2 as the underlying framework and twig as the template engine.
My problem is the following:
While this
{% for image in images %}
{{ dump(image.path is defined) }}
{% endfor %}
returns true for each element in the array,...
...but this one
{% for image in images %}
{{ image.path}}
{% endfor %}
throws an exeption.
Key "path" for array with keys "" does not exist
A twig-dump of the images-array returns this:
array(2) {
[0]=> object(stdClass)#2759 (9) {
["id"]=> string(5) "17795"
["typ"]=> string(3) "jpg"
["path"]=> string(10) "Tulips.jpg"
}
[1]=> object(stdClass)#2874 (9) {
["id"]=> string(5) "17796"
["typ"]=> string(3) "jpg"
["path"]=> string(14) "Hydrangeas.jpg"
}
}
This seems to be paradox to me and i really don't understand this. Has someone an Idea? I would be very thankful, deadlines are coming... :/
I think u created multidimensional array. Try foreach loop in twig template for image also
{% for image in images %}
{% for i in image %}
{{ i.datei }}
{% endfor %}
{% endfor %}
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