1

I'm trying to output paragraph field values in a sample paragraph template, but it does not work. I created a twig template in paragraph/paragraph--article--default.html.twig

I have a field called field_action and I tried:

{% block paragraph %}
    <div{{ attributes.addClass(classes) }}>
      {% block content %}
        {{content.field_action}}
        {{content.field_action.value}}

      {% endblock %}
    </div>
{% endblock paragraph %}

Nothing happens.

If I write {{content}} everything is fine, but I would like to customize output.

  • 1
    Is the block content necessary? Otherwise this should work fine. – Kevin Jan 17 '19 at 16:12
1

To print out single fields I usually use, {{ paragraph.field_action.value }}. That should also work for you.

In the case of an entity reference field, you need to use {{ paragraph.field_action.entity.field.value }}.

|improve this answer|||||

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.