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.
Create a CCK list field with checkboxes (allow multiple values).
Create a view with an exposed filter for that field.
Use operator "Is one of" and tick only the "Optional" checkbox.
As a result a multiple select box (size > 1) will be shown, however without the "multiple" HTML attribute being set so that only one option is selectable.
I found that "form_process_select()" in Drupal's form.inc is not being called for this exposed filter box. Maybe the "views_handler_filter_in_operator.inc" has to fixed in function value_form() ?
Comment | File | Size | Author |
---|---|---|---|
#13 | 1058464-no-multiple-select.patch | 1.42 KB | dawehner |
#11 | no-multiselect-exposed-filter-1058464.patch | 1.08 KB | chsoney |
Comments
Comment #1
dawehnerShort question: Are we talking about 7.x and fieldapi or 6.x and cck.
This is somehow important to get the starting point to fix this issue.
Comment #2
mindgame CreditAttribution: mindgame commentedSorry for using D6 terminology. It's indeed about D7.
I shall also add to the bug description:
When an option is selected from the exposed box it won't have any effect on the filtered result and the option will not remain pre-selected after the page load.
Comment #3
mindgame CreditAttribution: mindgame commentedComment #4
Alan D. CreditAttribution: Alan D. commentedCross posting. The exposed "country select list" from the countries module isn´t working, but I have had no time to investigate. #1061156: Countries - Views integration
Comment #5
johnvJust to add an easy test case:
- Add a filter for the default field 'Node translation: Language' to the view;
- Try to select a language: it doesn't work.
Comment #6
mindgame CreditAttribution: mindgame commentedQuick hack for my case where the original field is of type 'checkboxes':
I added this snippet in views/handlers/views_handler_filter_in_operator.inc, function value_form(), line 216 just before
Comment #7
amalaer CreditAttribution: amalaer commentedsubscribing
Comment #8
zbombicz CreditAttribution: zbombicz commentedsubscribing
Comment #9
seanrWe ran into this as well, but additionally, exposed filters with force single off when selected and submitted would not apply at all. Not sure if that's related or should be a separate issue, but basically exposed filters with multiple select appear to be completely broken right now in both the alpha and dev versions.
Comment #10
Dane Powell CreditAttribution: Dane Powell commentedI believe I'm also seeing this- I have added a simple List (Integer) field to user profiles, and added an exposed filter in a View with only the "optional" setting enabled. Thus, multi-select should be possible. Oddly, a multi-select box is presented but only one value can actually be selected at a time, and when changes are submitted the setting is simply lost.
Comment #11
chsoney CreditAttribution: chsoney commentedAlthough the form type for the "in" filter is "checkboxes," the method exposed_translate in the filter's parent class converts the element to a select control (the comments in the code say checkboxes do not work well with get requests). It is here that I think the code to add the processing hook belongs. I have added a patch which does that.
Comment #12
chsoney CreditAttribution: chsoney commentedComment #13
dawehnerI'm not 100% sure whether this is the right way to fix this.
Since some very new versions ctools_depedent_process is not needed anymore.
So why do we still change #process. Let's have a look at filter_in_operator.
The only place where process is added is
But is this still valid for drupal7? It's not.
So here is a patch
Comment #14
bojanz CreditAttribution: bojanz commented#13 is correct. That was D6-era code.
Comment #15
dawehnerCommited it with a small change(unneeded code)
Comment #16
johnv@dereine, can you provide the definitive version? Or can I still apply #13 ?
Comment #17
bojanz CreditAttribution: bojanz commentedFeel free to apply #13.
Compared to #13, an additional line was removed:
That's it.