Skip to content
Twig Field Finder
Theme

Loop over a multi-value field

Fill in your field name

Italic values are placeholders: replace them with your own machine names, or let the builder do it.

Reads the entity directly, before field formatters run.

  1. Twig
    {% for item in node.field_name %}
      {{ item.value }}
    {% endfor %}

Reads the content render array, after field formatters run.

  1. Twig
    {% for key, item in content.field_name|filter((item, key) => key|first != '#') %}
      {{ item }}
    {% endfor %}

Uses a contrib module’s Twig filter or function.

  1. {% for item in content.field_name|children %}
      {{ item }}
    {% endfor %}

Gotcha

Raw items expose their properties (value, target_id, entity…). Render-array children are the formatted items; keys starting with # are render properties, not items.

Contrib modules used

See helper modules for what each one provides.