Filter Criteria of Checkboxes in Views does not Loop through all values

Created on 15 December 2021, about 3 years ago
Updated 6 May 2024, 8 months ago

Problem/Motivation

Checkboxes option element from Webform when fed into a Views does not filter correctly.

Steps to reproduce

1) Create a webform

  • Choose textfield, add "Name" as title
  • Choose Checkboxes option element, title it "Categories" and write in several options (you must select the "checkboxes" plural so that the checkboxes are part of a grouped set)

    Create test submissions in which random combinations of the options are checked.

Here is my YAML from a simple webform

name:
  '#type': textfield
  '#title': Name
category_ies_:
  '#type': checkboxes
  '#title': 'Category (ies)'
  '#options':
    Biology: Biology
    Chemistry: Chemistry
    Math: Math
    Physics: Physics

2) Create a View from the Webform Submission

  • Create a view choosing the webform submission we just created.
  • Under fields import and configure the Name and Category(ies) fields.
  • Give them each a label and save.
  • Add Filter Criteria -- add a filter, under the Category dropdown select the webform submission, and then select the Categories field
  • Configure the Categories filter criteria: check the "Expose this filter to visitors, to allow them to change it"; under Operator, select "is one of"; in Options box select all of the categories including the All option. Hit Apply
  • Under the Advanced tab, check Use Ajax to yes.
  • Save View

Here is my example results: https://events.cancer.gov/views-error

The issue is that if you select Chemistry as the filter - -there are four records where Chemistry is a selected Catagory, but it only shows two records. It is only showing records where Chemistry is the first option in the list. The filter is failing to loop through all of the options. So if you Chose Biology and Chemistry -- it won't see the Chemistry, only Biology because it is listed first.

Proposed resolution

As you can see, this causes an issue if I want a list where Chemistry is one of options listed. I would like for the filter to be able to loop through all of the options and include records where Chemistry is a selected option, even if it is not the first on the values list. I can't even use the Sort Criteria to fix the issue, as checkboxes are not an option I am currently allowed to sort on.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

5.0

Component

Code

Created by

🇺🇸United States jnusraty

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024