Posted By

morningtime on 01/12/10


ajax jquery reset drupal views filters Exposed

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Drupal Views AJAX Reset Button for Exposed Filters in

 / Published in: PHP


What it does: clears & submits exposed filters form via AJAX (if enabled, otherwise normal page refresh).

This is for Views 2.x. It works with the 'remember me' option.

You need to create a custom module. E.g. custom/custom.module and custom/ Enable your custom module via admin/build/modules.

  1. function CUSTOM_form_alter(&$form, $form_state, $form_id) {
  2. if ($form_id == 'views_exposed_form') {
  3. $form['reset'] = array(
  4. '#type' => 'markup',
  5. '#value' => '<input '. drupal_attributes(array('type' => 'button', 'value' => t('Reset') )) .'onclick="javascript:$(this.form).clearForm();$(this.form).submit();" class="form-submit" />',
  6. );
  7. }
  8. }

Report this snippet  


RSS Icon Subscribe to comments
Posted By: diwwin on February 28, 2011

The button appears fine, but nothing happens when clicked. D6.20 Views2.

Posted By: diwwin on April 6, 2011

It only works when AJAX is used.

Posted By: devendramishra on February 15, 2016

This code is working for me. Thanks

You need to login to post a comment.