Grouped exposed taxonomy filter fails validation for autocomplete widget

Created on 29 September 2015, about 9 years ago
Updated 17 February 2023, almost 2 years ago

Problem/Motivation

When creating exposed grouped filters in a view, if a group is named and using autocomplete widget to add group items (can be taxonomy terms or users), the form throws the error on save:

The value is required if label for this item is defined.

Here is the screenshot of the error:

The problem behind this is that array of arrays is not recognized here:

$min_values = $operators[$group['operator']]['values'];
$actual_values = count(array_filter($group['value'], 'static::arrayFilterZero'));

In case autocomplete, it has the following data format:

[
  0 => [
    ' target_id' => 1
  ] ,
]

but the code above expects it to be:

[
  1 => 1
]

so it doesn't pass the filtering in static::arrayFilterZero

Affected plugins:

  1. \Drupal\user\Plugin\views\filter\Name ( πŸ› Views' User Name exposed group filter validation Needs work )
  2. \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid (this issue)

Steps to reproduce

  1. Install Drupal with "Standard" profile
  2. Open content view (/admin/structure/views/view/content)
  3. Add an exposed grouped filter by "Tags" (Taxonomy). Make sure the group item is using autocomplete widget
  4. Add at least one item to the group configuration
  5. Submit

Proposed resolution

Convert values into array with ids, which is expected by base filter plugin.

Remaining tasks

1) Wait for #1810148: Grouped exposed taxonomy term filters do not work because the group key is added to the query and not the taxonomy ID β†’ ;
2) Review/commit;

πŸ› Bug report
Status

Needs work

Version

10.0 ✨

Component
ViewsΒ  β†’

Last updated about 5 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States tkoleary

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

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.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Tested #64 as #65 steps were not provided.

    Can confirm the issue described in the IS and the steps were perfect.
    Applied patch
    Now am able to save the group filter without issue.

    Searching for loadMultiple($query->execute()); only none test file I saw was TermStorage.php

    Just to be extra safe could we do something like

            $terms = [];
            $results = $query->execute();
            if (isset($results)) {
              $terms = $this->termStorage->loadMultiple($results);
            }
    
Production build 0.71.5 2024