1

I found a solution that replaces the default reset functionality by an AJAX , It's working fine in my Bootstrap Theme , but I have one problem ! when I click the reset button the dropdown select list don't back to the Field Label but it's look empty ??!! what can i change to make it work ?

I'm using Drupal 7

/**
* Implements hook_form_alter().
*/

function MYMODULE_form_views_exposed_form_alter(&$form, &$form_state) {

// Get the submission button ID
$submit_btn_id = $form['submit']['#id'];

$form['reset']['#attributes'] = array('onclick' => "javascript:jQuery(this.form).clearForm();jQuery(this.form).find('#$submit_btn_id').trigger('click');return false;");

}
1
  • 1
    Something about this approach doesn't feel right. Why not use an #ajax callback(s) to clear and rebuild the form?
    – Kevin
    Feb 20, 2017 at 18:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.