I've been looking for something like this for a while but can't get it to work as described. I followed the readme exactly. I have an exposed filter as the controller field above the global dependent filter. I have the exposed dependent filter below the global dependent filter. Seems my dependent field shows no matter what. What am i missing? I tried both with ajax and without ajax. Is there some other setting somewhere?

Comments

joachim’s picture

> the controller field

You mean filter, right?

Which plugin are you using for exposed forms? I've only tested this with Basic and BEF.

In fact, can you export your view and paste it here so I can look at all its settings?

apmsooner’s picture

StatusFileSize
new49.53 KB

Yes, "controlling filter" would be better wording. I tried both basic and BEF with same result.

Code attached...

Thanks.

joachim’s picture

You've got a google map in there? Maybe you have JS clashes.
Can you try stripping the view right down to the essentials only?

nakara’s picture

hello I'm french sorry for my bad English, I have the same problem, I have followed the instructions from Readme.txt. dependent my filters are not hidden.

joachim’s picture

Component: Documentation » Code
Category: support » bug
Status: Active » Postponed (maintainer needs more info)

Same reply as to the OP: please strip your view right down to the barest essentials: remove any foreign plugins and reset options to their defaults to try and find out what is causing the problem.

nakara’s picture

I have try to create a view with different setup, I don 'use any plugin I have always seen my filters depend

joachim’s picture

Can either of you try to reproduce this with filters that exist in a basic install of Drupal, eg

- node type filter as controller
- node author as a dependent filter

apmsooner’s picture

I was able to get dependent filters to work per #7 instructions. My issue maybe is the google maps conflict... not sure cause its only attached to the attachment view but perhaps still a conflict. I'll try to recreate my view from the very ground level on up and see if i can pinpoint the problem.

nakara’s picture

#7 works for me but I am replacing author with a taxonomy its not works .

apmsooner’s picture

Okay, i've pinpointed my problems. It has nothing to do with conflicting javascript on other views. For some reason, a taxonomy field cannot be the controller field. If i used the example node type as the controller field and authorid as the dependent, it works fine but if i use a taxonomy field as the controller field and authorid as the dependent, the dependent shows no matter what.

apmsooner’s picture

Correction, my issue matches #9 which is taxonomy field as dependent field. I was using a normal select field as controller field and taxonomy field as dependent field in my test that failed. Hope that helps clarify the issue.

joachim’s picture

Title: Dependent filters not hiding.... » taxonomy term filters can't be used as controllers

Can you try re-enable killing of the filters early on by uncommenting at line 264:

    // We can kill the dependent filters now.
    // $this->filters_disable();

This should remove the JS behaviour so that you have to submit the form with the controller value to see the change in the filter. (I'm meaning to make that a UI option...)

Does the taxonomy filter work now?
If so that would pinpoint the problem to the JS dependency code.

nakara’s picture

i have uncommented / / $ this-> filters_disable ();
my field taxonomy is hidden, but impossible to display it this time.

apmsooner’s picture

I uncommented and it works when clicking apply for the first filter selection, the second dependent filter shows on page reload which is just fine for me.... not optimal but is a solution.

joachim’s picture

> not optimal but is a solution

Hehe that was the way this module was originally going to work; the JS stuff was extra icing I discovered I could do ;)

In which case it's a JS problem to do with picking up values from the filter's form element. Some firebugging and fiddling in views_dependent_filters_exposed_form_after_build() may help you find the cause.

apmsooner’s picture

Yeah i agree. It works for me with the uncommented code so I'm pretty okay with that as it is for now.

joachim’s picture

Title: taxonomy term filters can't be used as controllers » JS dependency fails for taxonomy term filters as controllers
Status: Postponed (maintainer needs more info) » Active

Updating title and status.

jvandooren’s picture

StatusFileSize
new13.82 KB
new14.04 KB

I have a yes/no field (published/unpublished) which is controlling a taxonomy field. I had the same issue as mentioned above and started debugging...

The problem is an incorrect filter_id in the form dependency. In my case, it is generating "edit-status_1" and "edit-status_1-1" (for BEF I guess) But if I change the foreach in views_dependent_filters.module on line 35 to the following, "edit-status-1" and "edit-status-1-1" is generated... This fixed my problem because this actually is the correct ID.

<?php
foreach ($dependency_info['controllers'] as $filter_id => $controller_values) {
      // Regular form.
      $filter_id = strtr(drupal_strtolower($filter_id), array(' ' => '-', '_' => '-', '[' => '-', ']' => '')); // <-- added this line
      $form_dependency['edit-' . $filter_id] = $controller_values;
      // better_exposed_filters form.
      foreach ($controller_values as $value) {
        $value = strtr(drupal_strtolower($value), array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
        $key = 'edit-' . $filter_id . '-' . $value;
        $form_dependency[$key] = array(TRUE);
      }
    }
?>

I don't know if BEF needs the "_" or the "-" but changing that is pretty easy :-)

joachim’s picture

Status: Active » Needs review
StatusFileSize
new2.01 KB

Yup, looks like this needs to use the core part of http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_htm... (which we can't actually call because it mucks around trying to be unique).

Could you try this patch please?

jvandooren’s picture

Yep, this fixed my issue!

I'll wait with RTBC untill someone with BEF tried the patch...

Thanks!

maxiorel’s picture

Confirm. The patch from #19 works with exposed taxonomy filters.

joachim’s picture

Status: Needs review » Fixed

- #1431606 by Ozmodiar, joachim: Fixed JS dependency for taxonomy term filters as controllers.

Committed the patch.

mxt’s picture

There isn't a DEV version to download in the project page: can you provide it?

Thank you very much.

joachim’s picture

Done; will take a few hours to show up as a download.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.