"Count the number 0 as empty" doesn't hide boolean fields unless output text is "0"

Created on 28 April 2016, over 8 years ago
Updated 13 July 2023, over 1 year ago

Problem/Motivation

When rendering a boolean field in views, it is currently not possible to hide the unchecked/off/0 value if you are using any Output setting other than "1/0".

Under No Results behaviour, there is a "Count the number 0 as empty" but this seems to work off the output value rather than the raw value.

Steps to reproduce

  1. Install the standard profile
  2. Add 2 Articles, one published and one unpublished
  3. Add a new Content view of Articles, remove the Published filter. Ensure the view style is Fields
  4. Add the Published field, set the Formatter to Boolean and Output format to anything other than "1/0"
  5. Under No Results behaviour tick "Hide if empty" and "Count the number 0 as empty"
  6. Preview the view
  7. Notice that both nodes published fields are displayed
  8. Edit the field again and change the output format to "1/0"
  9. Re-preview the view
  10. Notice that the unpublished node's published field has disappeared.

Proposed resolution

When checking empty with this field setting, compare the raw values rather than the rendered output.

Remaining tasks

Agree on approach
Tests
CR

User interface changes

Potentially would hide fields that weren't intended to be hidden previously.

API changes

N/A

Data model changes

N/A

Release notes snippet

πŸ› Bug report
Status

Active

Version

11.0 πŸ”₯

Component
ViewsΒ  β†’

Last updated about 4 hours ago

Created by

πŸ‡ΊπŸ‡ΈUnited States geerlingguy

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

    Worse Than Failure. Approximates the unpleasant remark made by Drupal developers when they first encounter a particular (mis)feature.

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