Not working correctly with boolean fields value 0

Created on 12 April 2022, over 2 years ago

We have a content type "petition" with a boolean field "is open" which means that people can sign the petition. On a landingpage with a views reference field we want to list all petitions which were successfully finished so they have the value "0" set for the field is "open". But when I edit the views reference field with an exposed filter for a boolean field to use the "false" value I get a completely unfiltered list of petitions.

I found that the issue lies in ViewsReferenceExposedFilters->alterView() in line 209:

        if (!empty($value) && isset($filters_by_id[$index])) {
          $filters[$index] = $value;
        }

For a boolean field with value false / 0 the check !empty($value) leads to "false" so that the filter is not added to the $filters array. I'll try to offer a patch...

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇩🇪Germany tobiberlin Berlin, Germany

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.

No activities found.

Production build 0.71.5 2024