I'm trying to learn how I can add or modify a markup for a specific filter on my exposed filter. I'm currently rendering the exposed filter using a block it has a lot of Drupal Generated Markup.

So far I've managed to identify the ID of the form, have been researching throughout the day for some examples but so far haven't had any progress

function iom_form_views_exposed_form_alter(&$form, $form_state, $form_id) {


Let say for example I have to add a label with a class and a custom class on the select element and wrap it with a div. Is there a way to build or construct that modified markup?

enter image description here


You can override the twig template responsible for that particular HTML output. You already see debug hints so you can see which template to check out.

Then copy that template to your subtheme and edit it there. Don't edit the core Drupal theme to avoid messing up your project maintainability.

Working With Twig Templates

You might be after select.html.twig and function template_preprocess_select.

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.