I'm getting an error notice on a views page on using this module.
It seems the dependent_exposed_filters array created in the handler doesn't exist or is not visible in the
views_dependent_filters_exposed_form_after_build function ( line 32 in the module file ).

I followed the instructions to set up a dependent filter. There's an integer select select list chosen as
the controller. Three of the possible integers have been ticked as values that will call the dependent filter
to be visible. The dependent filter is another select list that comes after the Global Dependent Filter. Both appear on the exposed form with the error message.

I'm using Views 3.1 and the exposed form is a simple Basic one. The view is listed in the attached txt file with a png of the error.

Is there something I've not set up properly ? As it seems to be working for other people, I'm wondering
if it's something outside of the module itself that causes the error. Have you any idea what could cause
the error ? Thanks very much for any ideas.

Comments

joachim’s picture

Status: Active » Postponed (maintainer needs more info)

Very strange.

Could you debug to check that the filter handler's exposed_form() is getting called?
And that $form_state['dependent_exposed_filters'] is set by the end of it?

Though as these two lines come together I really don't know how one can have an effect and not the other!

    $form_state['dependent_exposed_filters'][] = $dependency_info;
    $form['#after_build'] = array('views_dependent_filters_exposed_form_after_build');

(BTW: in future it's better for the maintainer as well as easier for you to just copy & paste error messages rather than take a screenshot, as it means I can search for text strings without having to retype them.)

janakiram’s picture

Notice: Undefined index: dependent_exposed_filters in views_dependent_filters_exposed_form_after_build() (line 32 of C:\wamp\www\sites\all\modules\views_dependent_filters\views_dependent_filters.module).
Warning: Invalid argument supplied for foreach() in views_dependent_filters_exposed_form_after_build() (line 32 of C:\wamp\www\sites\all\modules\views_dependent_filters\views_dependent_filters.module).
Notice: Undefined index: dependent_exposed_filters in views_dependent_filters_exposed_form_after_build() (line 32 of C:\wamp\www\sites\all\modules\views_dependent_filters\views_dependent_filters.module).
Warning: Invalid argument supplied for foreach() in views_dependent_filters_exposed_form_after_build() (line 32 of C:\wamp\www\sites\all\modules\views_dependent_filters\views_dependent_filters.module).

I also faced the same error. How do i get out of this error?

joachim’s picture

Help me by debugging, or upload something that will show me exactly what you have -- probably the content type + the view in a Feature would do it.

janakiram’s picture

StatusFileSize
new5.03 KB

i have tried this module on my local comp... uploading feature...

joachim’s picture

Status: Postponed (maintainer needs more info) » Active

Changing status so I spot this in my issue queue.

joachim’s picture

I've installed the feature, and added a few taxo terms in each of the vocabs Ram and Shop. Added a node and in

The master display works correctly with the dependent filters in Preview mode. The page doesn't show the filters but is that because it has different settings?

janakiram’s picture

I think the exposed filter block is enabled in the view.
so you have 2 change exposed filter block to left or right sidebar.

joachim’s picture

Title: Undefined index : dependent_exposed_filters on line 32 of views_dependent_filters.module » Exposed filters in block causes error: Undefined index : dependent_exposed_filters on line 32 of views_dependent_filters.module

Ok so the problem is the exposed filters being in the block...

For future reference: how to debug a problem like this: turn things off one by one until the problem goes away.

joachim’s picture

Status: Active » Needs review

Can you try this patch please?

gwynnebaer’s picture

@joachim, I don't see a patch attached to #10 above?

joachim’s picture

shergar’s picture

The patch in #12 worked ok when I applied it manually. The error message doesn't appear.

Then I had a problem with the controller not controlling the visibility of the dependent. As mentioned in the
other open issue ( http://drupal.org/node/1431606 ( #15 post ) ) there seems to have been a problem
with the key pairs created in the module file for the ctools dependency. The element id has underscores instead of hyphens. Replacing the underscores with hyphens gives the proper functionality.

I don't know enough to make a patch but the after build function now looks like this

function views_dependent_filters_exposed_form_after_build($form, $form_state) {
 if (!isset($form_state['dependent_exposed_filters'])) {
    return $form;
  }
  // We may have multiple dependency info arrays from more than one copies
  // of the views_dependent_filters_handler_filter_dependent handler.
  foreach ($form_state['dependent_exposed_filters'] as $dependency_info) {
    // Build up the CTools #dependency item to put onto each dependent element.
    $form_dependency = array();
    foreach ($dependency_info['controllers'] as $filter_id => $controller_values) {
        $elfilter_id = strtr($filter_id,array('_' => '-'));
      // Regular form.
      $form_dependency['edit-' . $elfilter_id] = $controller_values;
      // better_exposed_filters form.
      foreach ($controller_values as $value) {
        $value = strtr(drupal_strtolower($value), array(' ' => '-', '_' => '-', '[' => '-', ']' => ''));
        $key = 'edit-' . $elfilter_id . '-' . $value;
        $form_dependency[$key] = array(TRUE);
      }
    }
    // Set the dependency on each form element as required.
    foreach ($dependency_info['dependents'] as $dependent) {
      $form[$dependent]['#process'][] = 'ctools_dependent_process';
      if (!isset($form[$dependent]['#dependency'])) {
        $form[$dependent]['#dependency'] = array();
      }
      $form[$dependent]['#dependency'] += $form_dependency;
    }
  }

  return $form;
}

the only small change is $filter_id is replaced with $elfilter_id which has hyphens not underscores. If this change works for others, perhaps an update to the other issue could be made.

joachim’s picture

So just to check I understand correctly:

- the patch I posted fixes the problem you described here
- your latest comment and code is actually about #1431606: JS dependency fails for taxonomy term filters as controllers.

In future, please remember to keep comments related to the issues they are on, otherwise everything just gets too confusing!

gemariafm’s picture

Hi!

I have this problem:
Notice: Undefined index: field_asignatura1_value en views_dependent_filters_handler_filter_dependent->exposed_form() (line 252 of /Applications/XAMPP/xamppfiles/htdocs/drupal/sites/all/modules/views_dependent_filters/views_dependent_filters_handler_filter_dependent.inc).

I have tried everything that you said before, but i can't fix it... What can I do?

joachim’s picture

That's a different line in the code. Please file a new bug report.

rc_100’s picture

I was able to get this to work, using the above comments and one small hack. Here's what I did:

1. Patch in #12 didn't work for me, so I just manually patched the .module file.

2. Added the hyphen fix from #13. If you don't add this, it doesn't seem to show/hide the dependent filter.

3. Here's the hack. I changed the "Filter Identifier" for the controlling filter to be the same as the index that it said it was missing. Did the same for the dependent filter, too. In my example, the error said that it had an undefined index of "field_fooditem_main_category_tid" (which was my controlling filter), so that's what I changed the Filter Identifier to (it was just set to "tid" prior to that); for the dependent filter, I changed it's value from "tid_1" to "field_fooditem_sub_category_tid".

Seems to me that the $filter_id in line 252 of views_dependent_filters_handler_filter_dependent.inc contains the machine name, but what it really wants is the filter identifier (try dpm($input = $form_state['input']) to see that discrepancy).

Hope that helps someone, because this module is very cool once you get it working!

joachim’s picture

Thanks for your input!

I'm not sure however that I follow what you've changed. Could you post the changes that fix the bug described in this issue please? And any changes you've made for other problems, could you file new issues for (or check the queue for existing ones?). Thanks!

MaxKalkman’s picture

Hi,
I am a bit less familiar with applying patches / dealing with the code itself than the others in this thread so I'm sorry for having to ask things that are likely obvious.

Do I paste this patch from #12 into the views_dependent_filters.module at line 32? If not, where does it go?

Also since the patch from #13 seems to be a necessary step as well, which file/line should that be applied to as well?

And finally while I am able to change the filter identifiers I'm still unclear as to which identifiers RC_100 set the filters to to make it work.

Thanks,
Max

Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

#12 fixed the problem for me, and the patch applied cleanly. Thanks joachim.

saiya’s picture

hi there...

i also have a question same as #19 MaxKalkman about the patching.. anybody can help with this?

Posted by MaxKalkman on June 18, 2012 at 8:56pm

Hi,
I am a bit less familiar with applying patches / dealing with the code itself than the others in this thread so I'm sorry for having to ask things that are likely obvious.

Do I paste this patch from #12 into the views_dependent_filters.module at line 32? If not, where does it go?

Also since the patch from #13 seems to be a necessary step as well, which file/line should that be applied to as well?

And finally while I am able to change the filter identifiers I'm still unclear as to which identifiers RC_100 set the filters to to make it work.

Thanks,
Max

joachim’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Thanks for the review!

Committed.

Status: Fixed » Closed (fixed)

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

itqan-2010’s picture

patch in #12 worked for me Thank you ..

lukasss’s picture

I have the same problem and it can not be solved #13 and #12

lukasss’s picture

now I do not see any errors, but the views is always returns an empty

lukasss’s picture

ladinusamad’s picture

Hi, #13 sovled my problem ;) THX!