I would like to render my exposed fulltext search bar in a separate location from the rest of my search filters. My other exposed search filters are things like display number, sort order, etc... I am also using facets.

My current problem is that I need to render the search bar in a whole separate region from the rest of my exposed filters. My current solution is to render {{ exposed }} twice but then use CSS to display: none the items I don't want. This is just awfully hacky and is bad practice. Is there a way to split these forms into two separate exposed filters?

1 Answer 1


You can render one by one by:

{{ exposed.filter_1}}
{{ exposed.filter_2}}

And group them as your wish.

About the render {{ exposed }} twice as your current solution, The items you don't want can be removed at the .twig, not CSS such:

{{ exposed|without('filter_1', 'filter_2') }}
  • Thank you for your response! This has gotten me closer for sure. I am currently rendering my filters like this which visually achieves what I am looking for: {{ exposed|without('filter_1') }} {{ exposed|without('filter_2') }} The main problem though, because "exposed" is a render array containing a form. The two forms (with identical ids) are conflicting with each other. As an example, if I change the display setting, then the textfield resets its value, and if I change the textfield, then the other fitlers are reset to their defaults as well. Ajax is getting confused as well. Jun 1, 2022 at 13:09
  • You should take a look at core\modules\views_ui\templates\views-ui-expose-filter-form.html.twig. It display same filter form with separated parts by using {{ xxx|without('yyy') }} way. Besides, you can mix both (render one by one + render using |without) as my comment. Search form|without in Drupal core can give you some suggestions. Jun 2, 2022 at 2:02
  • Ah, I see what you are referring to! So this works in the filter form; however, the exposed variable is actually in the views-view.html template. I was actually able to utilize this rendering of separate elements in the form template as you have described because I lucked out and it worked with my layout. It does require me to inject a custom slider view inside of the exposed filter form to make it look like my design. BUT IT WORKS! For other cases, I may not get so lucky if the exposed filters need to be rendered in completely different regions. Jun 3, 2022 at 1:43

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.