I have a filter with checkboxes. When it is hidden by the controlling field, whatever checkbox was checked remains so even after the filter is hidden, and therefore still affects the view. I built this functionality a few years ago in D6 with a simple jQuery script. In that script, any time a controlling field hid a controlled field, that field was reset by the script so it wouldn't affect the view.

The auto reset behavior should be included in this module, or at least have the option to reset.

After reading Lullabot's write-up on this module, I was under the impression that the controlled field wasn't just hidden from view, but was also rendered inert. That doesn't seem to be the case.

Comments

druplicate’s picture

The problem I'm having is described here.
If I remove the independent filters such that I have just 3 normal exposed filters:

Filter 1: Content type selection (radio buttons, required filter)
Filter 2: Filter values for a field in content type A, optional filter
Filter 3: Filter values for a field in content type B, optional filter

The view works if only one of filters 2 and 3 have values (corresponding to the content type selected), but if there's a value in the filter for type A (or B), but type B (or A) is selected in filter 1, the view produces no results.

Adding two dependent filters to only show the filter for the content type selected breaks the view - no results under any conditions. I tried various combinations of AND and OR groups.

I can go back to the jQuery method but I really need a cleaner Views solution. This module should do the trick but it's not working as I expected.

joachim’s picture

I thought I put some code in the filter handling that dropped them from the query when they were hidden. Can you do some debugging in the filter handler?

druplicate’s picture

I'll try to debug it, but first I want to make sure that it's designed to work for this special case, where I'm filtering by content type and using that filter choice to control two other filters, each in a different content type. It appears that it shouldn't make any difference.

druplicate’s picture

Without any dependent filters, with node type "A" selected, and no options selected from filters 2 and 3, the view behaves as expected producing a query like:

SELECT node.nid AS nid, 'node' AS field_data_field_a_node_entity_type, 'node' AS field_data_field_b_node_entity_type
FROM 
{node} node
WHERE (( (node.type IN  ('a')) ))

Views ignores the presence of the filter for the content type that is not selected, if it has no option value(s).

But with dependent filters controlling filters 2 and 3 with node type "A" selected, and again with no options selected in either filter the query does not exclude the hidden filter's query part (Both filters 2 and 3 have the same options list [0,1,2,3,4,5].):

SELECT node.nid AS nid, 'node' AS field_data_field_a_node_entity_type, 'node' AS field_data_field_b_node_entity_type
FROM 
{node} node
INNER JOIN {field_data_field_b} field_data_field_b ON node.nid = field_data_field_b.entity_id AND (field_data_field_b.entity_type = 'node' AND field_data_b.deleted = '0')
WHERE (( (node.type IN  ('a')) AND (field_data_field_b.field_house_bedrooms_value IN  ('0', '1', '2', '3', '4', '5')) ))

In fact, for some reason the query is using the field of the opposite content type from the type selected in filter 1 - something's getting crossed. If I remove the dependent filter for the field in content type "B" the query still selects the field from content type "A" if content type "B" is selected. Selecting content type "A" gives the expected results (no options chosen for either filter 2 or 3).

I can try stepping through the handler code if I have time.

joachim’s picture

The code seems to have provision for killing hidden filters' values, so I don't know what's going wrong with it.

The situation with this module is that I am no longer working on the project it was developed for, so I don't have any paid time to work on it -- or free time for that matter.

If you can do some more debugging in the handler class to try to figure out what's going wrong, that would be great.

SUDARSHANDP’s picture

Priority: Normal » Critical
Issue summary: View changes
Issue tags: +Hiding filter does not reset it.

Hello

This module is great to use except auto reset problem. When we select any other value from the filter which controls the dependent filter then previous dependent selection need to be reset to default.

Without this feature it is difficult to use as functionality gets broken.

Regards
Sudarshan

Tushar Rana’s picture

hi SUDARSHANDP i am facing the same issue
if you have find any solution for this pls share.
Thanks in advance.

joachim’s picture

Issue tags: -Hiding filter does not reset it.

Please don't add random tags to issues -- read the tag guidelines please!

yuriy.sychenko’s picture

Hi, I have a dependent filters do not work with radio buttons from the BEF, you find some solution to this problem?