Drupal Views AJAX Reset Button for Exposed Filters in


/ Published in: PHP
Save to your folder(s)

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/custom.info. Enable your custom module via admin/build/modules.


Copy this code and paste it in your HTML
  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. }

URL: http://drupal.org/node/99370#comment-2465716

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.