I have a view with a single filter criteria (let's call it category) exposed to the user. The user can also select multiple categories in for this view (standard view stuff).

The category selection filter is rendered to the user in a big <select> for element. For aesthetic reasons, this is undesirable.

What I'm trying to do is override the display of the widget that renders out the <select> element. I've copied my /sites/all/modules/view/themes/views-exposed-form.php.tpl to my theme's folder, however, the widget itself (which contains the <select> form control I want to change to something else) is simply rendered by $widget->widget;

How can I change how the widget renders the multiple categories selection filter in the view?

Edit, for more info and clarity: This question deals with styling a widget, which is not quite what I want to do. I want to change the markup that renders the widget.

Another edit (after answering my own question): Turns out widget is not quite the correct Drupal terminology to use here for the exposed form filter.

  • What changes are you trying to make to it? You don't want it to be a select element or you're just trying to change its size (something css could do) or? Feb 13, 2013 at 3:02
  • I'm essentially trying to change the select element to a css-styled tabs or checkboxes, or anything that's not locked into that <select> form element
    – CamelBlues
    Feb 13, 2013 at 14:56

1 Answer 1


Ok, so after spending a day digging around the net, it seems that there are two ways to do this.

First off, for clarification, the exposed filter from the view is not a widget, at least in the Drupal sense of the word. In the traditional Drupal sense of the word, a widget is something used on an edit form or add form. Hooks like hook_field_widget_alter() and it's brethren operate on these widgets.

Just because the views-exposed-form.php.tpl has $widget as a variable, THAT DOES NOT MAKE IT A WIDGET!!!

Now that that confusion is out of the way, there are two ways to change the exposed filter.

  1. Add a custom module and use hook_form_alter to change things about the exposed filter form. I got as far as creating a custom module (called bypass) and creating a hook to display some simple debugging info:

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

when I discovered the Better Exposed Filters module.

  1. Use the Better Exposed Filters module to display the filters as checkboxes, radio buttons, etc. and style those.

Option 2 is what I'm doing now. Hope this helps someone :)

  • Thanks for clarifying the widget thing, it was very helpful.
    – MV.
    Feb 28, 2014 at 8:00
  • You don't need to create special module to use hook_form_alter() just use template.php in your theme drupal.org/node/1418546#comment-5522050
    – sobi3ch
    Oct 22, 2015 at 17:23

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.