Grouped exposed filter with "Allow multiple selections" ignores widget setting

Created on 20 March 2017, almost 8 years ago
Updated 30 January 2023, about 2 years ago

Problem/Motivation

When an exposed filter is using groups, and the Allow multiple selections option is enabled, the code ignores the configured selector (based on number of groups) and forces checkboxes:

    if (count($groups)) {
      $value = $this->options['group_info']['identifier'];

      $form[$value] = [
        '#title' => $this->options['group_info']['label'],
        '#type' => $this->options['group_info']['widget'], // This is the configured widget option.
        '#default_value' => $this->group_info,
        '#options' => $groups,
      ];
      if (!empty($this->options['group_info']['multiple'])) {
        if (count($groups) < 5) {
          $form[$value]['#type'] = 'checkboxes'; // Here it is forced to checkboxes if less than 5 groups.
        }
        else {
          $form[$value]['#type'] = 'select'; // Here it is forced to select.
          $form[$value]['#size'] = 5;
          $form[$value]['#multiple'] = TRUE;
        }

Proposed resolution

Don't ignore the configured widget setting.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
ViewsΒ  β†’

Last updated about 3 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States jhedstrom Portland, OR

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot β†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide β†’ to find step-by-step guides for working with issues.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    I also found out it ignores values. When I do have grouped filter for project status where values are Open,Closed, Cancelled. And select multiple Open and Closed it always shows 0 results even there are values. It works fine when I select only one value - Open or CLosed or Cancelled, but once multiple selected it shows 0 results.

    Any idea?

Production build 0.71.5 2024