[SOLVED][Drupal Views] How to add a 'reset' button to a Views exposed filters

| | 1 min read

Many Drupal users have wanted to know how to add a 'reset' button to a Views exposed filter as having a reset button allow for easy resetting of filtered forms. If you are faced with the same need in your Drupal website and want to know how to add a reset button to a Views exposed filter then continue reading.

Here is the two commonly suggested solutions.

  • Adding the following piece of code to one of their custom modules proved to be effective for many Drupal users
    function CUSTOM_form_alter(&$form, $form_state, $form_id) {
      if ($form_id == 'views_exposed_form') {
            $form['reset'] = array(
               '#type' => 'markup',
               '#value' => '<input '. drupal_attributes(array('type' => 'button', 'value' => t('Reset') )) .'onclick="javascript:$(this.form).clearForm();$(this.form).submit();" class="form-submit" />',
        );
        }
    }
  • A newer solution is to download and install the Better Exposed Filters module. This module provides a "Include Reset button" when you are creating a View.

Hope that helps.

The easiest way to solve a Drupal issue is to hand it to the Drupal experts. We offer Drupal Support and other Drupal services to help you maintain and manage your Drupal websites. Get in touch with us to know more.