I am creating a custom block with fields:

  • field_items_to_show (items to show)
  • field_logos (images, multiple)

The site editor must have the option to set the amount of items to show in a field.

in the twig field template field_logos I need the value from field_items_to_show

<div class="logos-slide-out">
    <div class="more-less wrapper d-flex-new flex-column align-items-center">
        <div class="itemstoshow row d-flex-new">
            {% for item in items %}
            {% if loop.index == 9 %} // this value must be set from field_items_to_show
        <div class="more-content itemstohide row d-flex-new">
            {% endif %}
            <div class="item col-sm-3 mb-30">{{ item.content }}</div>
            {% endfor %}

1 Answer 1


In a field template you find the parent entity in the variable element['#object'], from where you can get field values of other fields:

{% set field_foo_value = element['#object'].field_foo.value %}

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.