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() ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

Short 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.

mindgame’s picture

Sorry 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.

mindgame’s picture

Status: Postponed (maintainer needs more info) » Active
Alan D.’s picture

Cross 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

johnv’s picture

Just 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.

mindgame’s picture

Quick hack for my case where the original field is of type 'checkboxes':

      if ($which == 'value') {
        if (!empty($form_state['exposed']) && in_array($this->value_form_type, array('checkboxes'))) {
          $process[] = "form_process_select";
        }
      }

I added this snippet in views/handlers/views_handler_filter_in_operator.inc, function value_form(), line 216 just before

      if (!empty($process)) {
amalaer’s picture

subscribing

zbombicz’s picture

subscribing

seanr’s picture

We 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.

Dane Powell’s picture

I 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.

chsoney’s picture

Although 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.

chsoney’s picture

Status: Active » Needs review
dawehner’s picture

I'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

      if ($this->value_form_type == 'checkboxes') {
        // If this form element will use checkboxes in the UI, we need to
        // check_plain() all the options ourselves since FAPI is inconsistent
        // about this. However, instead of directly doing that to the #options
        // right now, we define a #process callback since we might change our
        // mind later and convert this into a 'select' form element, which
        // would lead to double-escaping the options.
        $process[] = 'views_process_check_options';
      }

But is this still valid for drupal7? It's not.

So here is a patch

bojanz’s picture

Status: Needs review » Reviewed & tested by the community

#13 is correct. That was D6-era code.

dawehner’s picture

Status: Reviewed & tested by the community » Fixed

Commited it with a small change(unneeded code)

johnv’s picture

@dereine, can you provide the definitive version? Or can I still apply #13 ?

bojanz’s picture

Feel free to apply #13.
Compared to #13, an additional line was removed:

$process[] = "form_process_$this->value_form_type";

That's it.

Status: Fixed » Closed (fixed)
Issue tags: -exposed filter multiple select

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