1

I have Matrix field containing block with various fields. How can I output into template label of single field?

Can I get type of that field? (for example - textfield, dropdown field, etc.)

1 Answer 1

2

Something like this should do what you're looking for:

{% for block in entry.body %}

    {% set fields = block.getFieldLayout().getFields() %}

    <ul>
        <li>{{ block.getType().name }}
        <ul>
            {% for field in fields %}
                <li>{{ field.getField().name }}
            {% endfor %}
        </ul>
    </ul>

{% endfor %}
2
  • I want to output label of field, not value of field. Commented May 8, 2017 at 9:03
  • Sorry, misunderstood the question. Updated answer.
    – Brad Bell
    Commented May 8, 2017 at 22:56

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.