2

I have created a view with four exposed filters. In exposed form settings, I added a reset link and used auto submit option. Filter and reset works fine without error, but I want to show the reset button only when the filter is applied. If no filter is applied, there should not be reset button.

I have searched, but I didn't find any solution.

How can I achieve this?

0

hook_form_alter() can also do this

function module_form_alter(&$form, &$form_state, $form_id) {
  if($form_id == 'Your_form_id") {
    if (!$form_state['view']->exposed_input) {
      unset($form['reset']);
    }
  }
}

You will have some other value for ['view']->exposed_input. Use dpm(0 to get the exposed_input value. ['view']->exposed_input returns nothing if filter is not applied. Hope it works.

0

You can achieve this either using custom module[hook] or jQuery.

Using jQuery

  1. Hide Reset button using CSS display:none.
  2. Now in jQuery, on page load, check for URL containing Query String.

Example: [view-URL]/?type=page.

  1. If URL contains any Query String, then make Reset button visible.
  • How can do it using form alter @Nikhil Banait – user50991 Oct 23 '15 at 6:22
  • Sorry, I am not the right person to explain you Custom thing :( – Nikhil Banait Oct 23 '15 at 6:25

Your Answer

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