Adding an 'All' option to a views exposed filter I have a Views exposed filter, that allows multiple items to be selected. It's based on the 'Allowed values' for a multiselect CCK field.

The exposed filter comes out looking like this:

Option 1
Option 2
Option 3


I need to add an 'All' option to the top, so that it would be:

All
Option 1
Option 2
Option 3


Clicking the All option should have the same effect as holding Ctrl and clicking on Options 1, 2 and 3. ie. return all nodes that have a value of Option 1, Option 2 or Option 3 for this field.

How can I add such an option to my widget? I'm sure it could be done through form_alter somehow, but I can't suss out how.
OK... I think I may have cracked it.

function mymodule_form_alter(&amp;$form, $form_state, $form_id) { 
  if ($form_state['view']-&gt;name == 'myview') {
    // Add our custom All buttons.
    $form['myfield']['#options'] = array("-ALL-" =&gt; t("- All -")) + $form['myfield']['#options'];
    array_unshift($form['#submit'], 'mymodule_exposed_form_submit');
  }
}

function mymodule_exposed_form_submit(&amp;$form, &amp;$form_state) { 
  if (!empty($form_state['values']['myfield']['-ALL-'])) {
    $options = $form['myfield']['#options'];
    unset($options['-ALL-']);
    $form_state['values']['myfield'] = $options;
  }
}


So basically I add in my 'All' item at the top of the select. Then I add my own custom submit handler before Views' one.

In my submit handler, I check for the presence of the All option, and if its found, I adjust the selected options so that all options are selected except for the All option.

Seem to work :)