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.)

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 %}
| improve this answer | |
  • I want to output label of field, not value of field. – Filip Bartnicki May 8 '17 at 9:03
  • Sorry, misunderstood the question. Updated answer. – Brad Bell May 8 '17 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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