1

How do you get a list of the fields that are on an entry?

I tried {{ dump(entry.subentry) }} but that isn't any help ...

1 Answer 1

3

I think you can use this:

{% for field in entry.subentry[0].getFieldLayout().getFields() %}
    {{ field.getField().name }} {# or .handle #}
{% endfor %}

You might try a great little plugin called inspector that prints out all of the attributes and methods of an object using either filter {{ entry.subentry|inspect }} or method {{ inspect(entry.subentry) }} syntax. Its output is a little cleaner than dump, and nice for following the rabbit-hole.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.