Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
First, thanks for making this feature available. I'm trying to remove the -any- option from the final list of options in the exposed filter. With the original exposed filter, this was done by making it required and only single value. How is this done with your change?
When I select [Required] on the exposed filter, I get the following error:
No valid values found on filter: Class (field_cum_class) (selective).
And cannot save the view. Any help would be great.
Comment | File | Size | Author |
---|---|---|---|
#1 | required.patch | 1016 bytes | david_garcia |
Comments
Comment #1
david_garcia CreditAttribution: david_garcia commentedPlease try with attached patch and give feedback.
Greetings,
Comment #2
fluxline CreditAttribution: fluxline commentedthanks for the quick fix! it does fix the error, and removes the -any- option.
now for the bad news, the filters are also being used as inherited exposed filters on a views attachment. it breaks those filters, and the entire table with all values is shown. i have also set the inherited filters on the attachment to required, but it doesn't help.
please let me know if you need anything and thx again.
Comment #3
fluxline CreditAttribution: fluxline commentedComment #5
david_garcia CreditAttribution: david_garcia commentedI've been working on the module and came accross some interesting situation with required selective filters.
The values shown in the selective filter depend on the values of all the other filters in the view. If you have more than one selective filter in a view, and one or more or them are marked as required, then the only way of correctly calculating these interdependent values (as we have no default values for these filters at design time) is some sort of complex iterative execution of queries.
Very simple example:
Filter A is set to SELECTIVE but not required
Filter B is set to SEELCTIVE but required
If the Hanlder for filter A runs before Filter B, there is no way of knowing the constraints that filter B is going to set in the query in order to obtain the values for filter A.
One can think that an easy fix is to execute Filter B, choose a default value, and then execute filter A, but....what happens if in the same view you throw in the game a third selective filter, Filter C, that is also set to required.
In that case the values of Filter B depend on the values of Filter C, and the other way round, so the solution is not as easy as it might look like.
This problem is also extensible to views not using required if more than one selective filter is present.
¿What is supposed to happen if the user selects incompatible values from these two filters? Then we have a mess because one or both of the filters have a value that is no longer present in the result set.
If you are using BEF with autorefresh then the problem goes away because as soon as the user picks an option, the other filters will refresh showing only the values present in the result set.
Comment #6
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedI am afraid that using BEF + autosubmit does not solve the problem when the view is first loaded because of the required filter, the non-required filters are empty.
Comment #7
allenfantasy CreditAttribution: allenfantasy commentedHi all, I found myself stuck in a similar issue which is a bit complicated:
1) Here I have a content type called Product, which has a field as Entity Reference to another content type Meta. ( 1 Product may have more than 1 Meta)
2) Meta has two fields called "unit" and "color", which are both Taxonomy.
3) And I want to build up a View which would show all "Meta"s of single Product, so has a contextual filter: Content: Nid
3.1) Since the customer asks me to add filters to the view, I add "unit" and "color" as filter, using Views Selective Filters ( I add the "unit" and "color" of Meta to the display fields by using Entity Reference, then add selective filters of "unit" and "color"). Until now everything works fine.
3.2) Then the customer asks me to remove the "Any" option, so I just set the filters to "required" both - then the filters are both disappeared, and all the metas are displayed, it seems that the filters are not working.
Can anyone has a clue of this or had met this issue before? I searched for several hours in Google but didn't found the solution. Any help or tips would be much appreciated.
P.S: I am using Views 7.x-3.11, Views Selective Exposed Filters 7.x-1.4, Drupal 7.37
Thank you and best regards,
Allen
Comment #8
bfuzze9898 CreditAttribution: bfuzze9898 commentedI found a similar and, I think, related scenario. I have a view with 2 displays:
Display 1: I am using a required selective filter
Display 2: I'm not using ANY selective filters
For display 2, everything saved correctly until I tried to modify the "Exposed Form" settings under Advanced. Then I got the following error:
In the displays list, Display 1 is highlighted (validation error border), even though I never made any changes to that display and the filters are valid.
Work-around: After reading this thread, I disabled required on Display 1 and was able to save Display 2, then re-enabled required on Display 1.
I am using Views 7.x-3.13 and Views Selective Exposed Filters 7.x-1.4
Hope this helps you debug this issue. Thanks for this feature, it is very useful. Selective filters should be a added to Views core module (IMHO ;) ).