Unable to access nested object properties using TWIG

Tl; DR Twig won't let me jump to a nested object.

I have a collection of json_decoded objects nested inside it with a nested object. When I try to display the property of a nested object, I get an error, for example:

The text element for "" does not exist

when I try to dump a nested object, I see that this is normal ... but I can’t access any of its properties. Here is a dump of the "whole" parent object

Using this in my loop
{% for item in allFields %}

    {{ dump(item) }}

{% endfor %}

Full dump

And here is a dump of the nested label object using it <{dump (item.label)}} in my loop

Using this in my loop
{% for item in allFields %}

    {{ dump(item.label) }}

{% endfor %}

Label dump

I am trying to get the text property (and others) of the label class using a tweak for the loop:

{% for item in allFields %}

    {{ item.label.text }}

{% endfor %}

And this is where I get the error message

The text element for "" does not exist

+5
1

. : , EntityManager - . , , .

, allFields?

, :

{% for item in allFields %}

    {{ item.label is null or item.label == "" ? "***EMPTY-LABEL***" : item.label.text }}

{% endfor %}
+3

All Articles