I have a #states on the exposed filter form as follow:

If field_a == 'b' then field_b show, field_c hidden;

else if field_a == 'c' then field_c show, field_b hidden;

All fields here are Select list.

The states is working fine, problem is the value of the hidden filter is affecting the view result, which i dont want.


1) How to change the hidden field value back to default(to -Any- in Select List)? JQuery maybe?

2) How to avoid the hidden filter affecting the view result and to remove the filter (?...&field_b=xxx) in the query string?

updates: working code for states.

 $field_state = array( 'visible' => array(':input[name="field_a"]' 
 => array( array('value' => 'a') )),       );

 $form['field_a']['#states']   = $field_state 
  • Hello, have you tried something to achieve this? Please share your code and whatever issue you have found. Commented Dec 25, 2013 at 13:05
  • @JayendraKainthola, I have tried the hook_views_pre_view to unset the filter, but the query string still unchanged. hook_form_alter does not help much also.
    – Kent
    Commented Dec 26, 2013 at 1:17
  • you should update your question with your code and you should ask only question. Commented Dec 26, 2013 at 2:13
  • @JayendraKainthola, i dont have any working code for my question. The questions are related. Do you have the answer for my questions?
    – Kent
    Commented Dec 26, 2013 at 4:52
  • If you do not have any working code, then how you manage the #states functionality as you mentioned that The states is working fine. Sorry, we can't answer to your question if we do not have enough information about your functionality. Commented Dec 26, 2013 at 5:10

1 Answer 1


Though you have custom solutions in place, but a try for views_dependent_filters can be worth, this might be hint as well for your custom solution.

views_dependent_filters module:

Allows the presence of exposed filters on a view to be controlled by values in another exposed filter. Dependent filters are hidden when not relevant, and their values are not considered when the exposed form is submitted.

The module is compatible with both the Views basic and the Better Exposed Filters form plugins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.