Hello,

I was wondering if it is possible to get conditional fields working for Views Exposed Filter?
Any pointers would be very much appreciated.

Thank you

Comments

also interested in this

+1

+1 this would be great!

+1 subscribing

Great module! Is this new feature something possible in the near future?

+1 subscribing.

+1 subscribing

+1 subscribing

+1 subscribing

Check out CTools and a hook_form_alter to set this up programmatically, though it would be cool if it could be done in UI.

hi manatwo,

would you know of any good tutorials or a resource to learn how to achieve this with CTools and hook_form_alter?
if we could share examples in this issue thread it would be awesome!

thanks

subscribing !!

+ 1 subscribing!

subscribing

looks like this is nothing more than wishful thinking, wish i could write it and contribute it, good luck to anyone who tries, i've had no luck. would be really nice =D

I solved it by using a simple jQuery script. In this case I have two radio buttons to select "Rent" or "Buy". This is controlling the visibility of sales or rental price range fields for Views exposed filters. Just place the jQuery script in your js directory in your theme, and list it in the .info file. Use this script as a guide and Google around for jQuery script examples for showing/hiding elements. That's what I did to come up with this script, not having any previous experience with jQuery. Easy enough to substitute your variables and modify anything else. You can also control animation effects with additional jQuery statements. The trickiest part was learning the details of moving action selectors up or down the DOM to find the appropriate trigger and target, but it's straightforward to do. MUCH easier to try/debug using the live script console in Firebug. Also, learned most of what I needed to do here by watching the Lullabot video on jQuery.

(function($){
$(document).ready(function(){
       $('#edit-field-list-rent-1yr-amount-min-wrapper').parents('div.views-exposed-widget:first').hide();
       $('#edit-field-sell-rent-value-many-to-one-Rent').click(function(){
       $('#edit-field-list-rent-1yr-amount-min-wrapper').parents('div.views-exposed-widget:first').show();
       $('#edit-field-sales-price-amount-min-wrapper').parents('div.views-exposed-widget:first').hide();
});
       $('#edit-field-sell-rent-value-many-to-one-Buy').click(function(){
       $('#edit-field-list-rent-1yr-amount-min-wrapper').parents('div.views-exposed-widget:first').hide();
       $('#edit-field-sales-price-amount-min-wrapper').parents('div.views-exposed-widget:first').show();
    });
  });
})(jQuery);

+1

I too need to be able to configure a certain exposed filter to dynamically (dis)appear only if some other exposed filter is set to certain (!) values. I found this possible solution (which I have not tested myself yet): http://drupal.org/node/358019

Also interested

I need to do the same, but my controlling field is taxonomy term list. If someone has an idea how to do it in Drupal, please do tell. I'll post here later with a solution if I have to go the jQuery way.

+1 subscribing

how do you find this "#edit-field-sell-rent-value-many-to-one-Buy" what part of the view does it refer to.
Thanks

That Views field is specific to the filters I had setup.

You would have some different fields to refer to for your application.

You can use Firebug to find the HTML with your specific tags.

Thanks druplicate @ #15 this helped me. What I had was kind of the same problem except that the 'Rent' & 'Buy' where options in a select element not buttons.

Here's how it worked for me, hoping it helps more ppl who want to show/hide filter based on select element values

$(document).ready(function(){
  $("#edit-field-prop-sellpmax-value-wrapper").parents("div.views-exposed-widget:first").hide();
  $("#edit-field-prop-listing-value").change(function(){
    if($("#edit-field-prop-listing-value option:selected").val() == "4" ) {
      $("#edit-field-prop-sellpmax-value-wrapper").parents('div.views-exposed-widget:first').show();
    } else {
      $("#edit-field-prop-sellpmax-value-wrapper").parents('div.views-exposed-widget:first').hide();
    }
  })
})

Could you please elaborate a little more on that, i don't know much php but will be able to swap out your fields with mine.also, does this go in templete.php?
My fields:
System:select list (always active) (allowed values PC, XBOX, PS3, Wii)
Video Type: select list (always active) (allowed values Strategies, Commentary etc)
Game: select list (depending on which game the user selects, the following fields will be determined) (values Black Ops, Modern Warfare 2 etc)
Game Types: (will depend on which game is choosen)
Maps: (will depend on which game is choosen)

I will really appreciate your help.

Subscribe

Status:Active» Closed (won't fix)

Conditional Fields only works with CCK fields, it doesn't have anything to do with Views exposed filters.
I thinks that the functionality you need is included in Views Hacks: http://drupal.org/project/views_hacks (the Views Selective Exposed Filters module).

For a javascript solution, this is the one i use. '
It works better than the ones above and reset the hidden select to the first value on hide. Hope that can help someone.

$("#edit-genre").change(function() {
var field = $('#edit-music-genre');
if ($("#edit-genre").val() == "Music")
{
$("#edit-music-genre-wrapper").parents('div.views-exposed-widget:first').show();
}
else
{
$("#edit-music-genre-wrapper").parents('div.views-exposed-widget:first').hide();
field.val($('option:first', field).val());
}
     });
$("#edit-genre").change();
});

@alioso_oopa
Yeah, it's working fine but only when Ajax is disabled. If Ajax is enabled then it displays all the filters even though we try to hide it using javascript. When Ajax is on, it loads the whole view again after processing the template file so all the filters will be displayed. Any idea how those filters can be hidden in this case?

Any news about this? No patch or dev release including this option?

I'm having the same issue that mittalpatel and it seems to be a lack of ajaxComplete implementation but I can't make it work.

Btw, is this a duplicate of: http://drupal.org/node/358019?

#29 This should help:

jQuery('#<SUBMIT TAG>').click(function(){
jQuery(document).ajaxComplete(function(e, xhr, settings) {
//console.log(settings.url);
if (settings.url ==  '/site/views/ajax' ){
<HIDE FUNCTION>() ;
}
});