Reputation: 1625
Tl;DR Twig won't let me drill down into a nested object.
I have this collection of json_decoded objects that has a nested object within it. When trying to output a property of the nested object I get an error like:
Item "text" for "" does not exist
when I try a to dump out the nested object i can see it fine... but I can't access any of it's properties. Here's the dump of the "entire" parent object
Using this in my loop
{% for item in allFields %}
{{ dump(item) }}
{% endfor %}
And here is the dump of the nested label object its self using {{dump(item.label)}} in my loop
Using this in my loop
{% for item in allFields %}
{{ dump(item.label) }}
{% endfor %}
I'm attempting to get the text property (and others) of the label class by using a twig for loop like so:
{% for item in allFields %}
{{ item.label.text }}
{% endfor %}
And it is here that I get the error
Item "text" for "" does not exist
Upvotes: 6
Views: 4274
Reputation: 20193
That is weird. One though: this happened to me on one occasion when my EntityManager
was running out of memory due to very complex hydration query. I'm thinking that some part of data gets lots here and you get this error.
So, how many item do you have in this allFields
list?
In order to troubleshoot this I suggest you do:
{% for item in allFields %}
{{ item.label is null or item.label == "" ? "***EMPTY-LABEL***" : item.label.text }}
{% endfor %}
Upvotes: 4