I need to print out a list of checked form options in a TWIG template in Drupal 8.

I'm using Better Exposed Filters, and editing the views-exposed-form.html.twig template.

1 Answer 1


Iterate over the form options, returning the # value of each item:

{% for choice in form.filter['#value'] %}

Then Print out the title value of each one of those options:

{{ form.filter[choice]['#title'] }}

All together it looks like this:

{% for choice in form.filter['#value'] %} {# Find each checked option #}
  {{ form.filter[choice]['#title'] }} {# Print the Title #}
{% endfor %}

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.