Notice: Undefined index: country in views_dependent_filters_handler_filter_dependent->exposed_form() (line 267 of /var/www/mysite/sites/all/modules/contrib/views_dependent_filters/views_dependent_filters_handler_filter_dependent.inc).

I receive the above error, and the dependent fitler is never hide.

My configuration:

I'm using LOCATION module, and I have an exposed filter "location:country" that have to show the exposed filter "location:distance/proximity" only when a defined country is chosend from first field ("italy" in my case).

Nothing works and alla exposed filters are always shown.

Notice that I've also applied patch in http://drupal.org/node/1441352#comment-5631010 but without success.

Thank you very much for resolving this.

Comments

jibus’s picture

Same here :

Notice : Undefined index: type dans views_dependent_filters_handler_filter_dependent->exposed_form() (ligne 267 dans /var/www/localhost/www/sites/all/modules/views_dependent_filters/views_dependent_filters_handler_filter_dependent.inc).

Type filter field is the depend exposed field.

Ted51’s picture

I have the same problem when I use Search API module. Is very fine without this module

errev’s picture

I got the same problem.
I exposed in block for Search with Search API.

errev’s picture

It looks like, no issue for this one.
Nobody is careing

joachim’s picture

I'm afraid that I no longer have much time at all to look after this module, as I am no longer working on the project it was initially developed for.

Cab you debug and do some of the work towards figuring out where the problem lies?

kyletaylored’s picture

This worked for me.

vivdrupal’s picture

Issue summary: View changes

Patch in #6 removed the error for me.

Thanks

narkoff’s picture

The patch in #6 removed the error for me as well. Thanks @kyletaylored.

aczietlow’s picture

I had a similar issue with using this module with search API. The patch #6 removed the error, and still works as intended. @kyletaylored ++

kyletaylored’s picture

Status: Active » Needs review
nwom’s picture

Version: 7.x-1.1 » 7.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

#6 worked for me as well. I think this is RTBC.

nwom’s picture

Status: Reviewed & tested by the community » Needs work

Nevermind, it most likely needs to be rerolled for the current dev.

alex.bukach’s picture

Status: Needs work » Needs review
StatusFileSize
new1.59 KB

The patch from #6 seems to contain an mistake that kills the module:

if (!isset($form_state['input'])) {
   // Get the input for this filter.
   $input = $form_state['input'][$identifier];
   ...

This conditions is always false (since at that stage there exists $form_state['input'], at least empty), and therefore the code inside never works (and hence does not throw an error), and dependent filters aren't killed when they should.

Here's another patch that must fix the issue preserving module functionality.

kyletaylored’s picture

Man, what was I thinking 2 years ago... Sorry, I was a little green. Haha.

#13 looks much better.

mustanggb’s picture

Patch got rid of the error messages, but it didn't solve the problem, which is that when a user visits the view for the first time the form_state input is empty, so the view results don't reflect the filter settings.

In-case it matters my exposed filters form is in a block.

mustanggb’s picture

So here is my take on it, if a value hasn't been set through the exposed filter it uses the default value instead, which is the value the exposed filter will use anyway.

views_dependent_filters_handler_filter_dependent.inc

     function exposed_form(&$form, &$form_state) {
       ...
       // Get the input for this filter.
-      $input = $form_state['input'][$identifier];
+      if (isset($form_state['input'][$identifier])) {
+        $input = $form_state['input'][$identifier];
+      }
+      else {
+        $input = $form[$identifier]['#default_value'];
+      }
       ...
     }
mustanggb’s picture

StatusFileSize
new937 bytes

And a patch of #16.

john cook’s picture

Status: Needs review » Reviewed & tested by the community

Patch #17 fixes the problem.

donquixote’s picture

With this patch I now get

Notice: Array to string conversion in views_dependent_filters_handler_filter_dependent->exposed_form()

in this line:

      $intersection = array_intersect($input, $controller_values);

I suppose this is because of this:

      // Convert values for non-multiple filters to an array.
      if (!$this->view->filter[$filter_id]->options['expose']['multiple']) {
        $input = array($input);
      }

If $input is already an array, then array($input) will be a nested array, which blows up array_intersect().

In my case, the filter is NOT configured as "multiple", but Views still stores an array as the default value.
- Filter type to expose: Single filter
- Required: Yes
- Operator: "Is one of"
- Expose operator: No
- Value: Checked "Category 1", "Category 2", "Category 3" (out of 7 categories)
- Allow multiple selections: No
- Remember the last selection: No
- Limit list to selected items: Yes

The view is a search API view, and the filter is for "content type".

I would say this is a bug in Views.
Or maybe it is caused by bef or vefl, which I also have enabled.