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:
- \Drupal\user\Plugin\views\filter\Name (#2920039: Views' User Name exposed group filter validation)
- \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid (this issue)
Steps to reproduce
- Install Drupal with "Standard" profile
- Open content view (/admin/structure/views/view/content)
- Add an exposed grouped filter by "Tags" (Taxonomy). Make sure the group item is using autocomplete widget
- Add at least one item to the group configuration
- 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;
2) Review/commit;