If I create a new "is empty (NULL)" or "is not empty (NULL)" filter and expose it, the resulting UI makes no sense. It's an empty text box with an Apply button. Huh?

These filters are binary--either on or off. All you need is a toggle. Filling out a field and pressing Apply makes no sense and provides no obvious way to set or unset the filter.

What might be nice is a single trinary filter on null with three selections:

  • No selection (filter inactive)
  • Empty
  • Not empty

Comments

markus_petrux’s picture

Status: Active » Postponed

postponing until someone can come up with a patch for review.

PS: Changing issue status helps track which issues have been already visited.

markus_petrux’s picture

Status: Postponed » Closed (duplicate)
aren cambre’s picture

Status: Closed (duplicate) » Active

No, this is about the UI, not about the behavior. The UI makes no sense.

markus_petrux’s picture

For some reason I don't see a problem with the UI of the exposed filter. I see a dropdown where I can choose one of several operators, including Empty/Not empty. And a text box that is only visible depending on the operator selected. For the Empty/Not empty operator, this text box is not visible at all.

Are you using latest version of Views? ...well, I think it is Views who renders this exposed filter and it seems to me it's been fixed recently.

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)
aren cambre’s picture

Status: Postponed (maintainer needs more info) » Active
StatusFileSize
new30.86 KB
new16.77 KB
new25.75 KB

See attached images.

markus_petrux’s picture

Title: UI for some exposed filters makes no sense » UI for empty/not empty filters makes no sense when "Unlock operator" option is not enabled
Project: Content Construction Kit (CCK) » Views (for Drupal 7)
Version: 6.x-2.5 » 6.x-2.x-dev
Component: Views Integration » exposed filters

Oh, I see what happens. If you check the "Unlock operator" you'll be able to change the operator in the exposed filter form, and choosing EMTPY/NOT EMPTY hides the text field. But when the "Unlock operator" option is not enabled, the exposed filter form becomes a textfield.

Well, this behavior is implemented by Views in filter handlers such as views_handler_filter_string.inc, views_handler_filter_numeric.inc, etc.

I'm not sure if this has already been reported to Views. Hopefully views maintainers can give you a better pointer on this.

aren cambre’s picture

Title: UI for empty/not empty filters makes no sense when "Unlock operator" option is not enabled » Cannot set exposed binary filters without "Unlock operator"
Issue tags: +Usability
StatusFileSize
new7.22 KB

I was going to create a separate issue for a new problem, but I found it's related to this: If I create two exposed empty/not empty filters on the same view, it looks like I get only one Apply button for both. See attached image.

I then remembered this is the single Apply button to apply all options set by the user for all filters.

This emphasizes the need for some way to toggle exposed binary filters.

giorgio79’s picture

+1

I exposed and unlocked a filter for a single on off checkbox of integer type that only has two values,

0|No
1|Yes

When I filter for EMPTY, the filter does not work.

Also,
"is empty (NULL)" or "is not empty (NULL)" should read
"is empty (NULL)" or "is not empty (NOT NULL)"

fatstar415’s picture

StatusFileSize
new1.4 KB

Patch for this issue

Please note that this patch is not made relative to the module's root directory.

Please apply patch under the folder handlers/ in your views root directory.

fatstar415’s picture

Status: Active » Fixed
giorgio79’s picture

Status: Fixed » Needs review
dawehner’s picture

aren cambre’s picture

Status: Closed (duplicate) » Active

Hmm... are you sure? This seems like a more generic version of #477984: CCK field is empty/not empty filter doesn't work when exposed.

dawehner’s picture

Sorry. I got confused by all this patches.

fatstar415’s picture

StatusFileSize
new878 bytes

Copy right removed. Updated.

dagmar’s picture

Status: Active » Closed (duplicate)

Ok, it seems to be the same patch on both issues, marking as a duplicate of #477984: CCK field is empty/not empty filter doesn't work when exposed

mecano’s picture

Status: Closed (duplicate) » Active

It is not the same issue !
This is an UI issue where exposing an "is empty" filter results in the incapacity of switching it off.
In #573298: Cannot set exposed binary filters without "Unlock operator", Aren Cambre is proposing a trinary UI but logically I guess it should be a binary UI (True/False), reset can be implemented by View Hacks, radio button would be nice (note that Better Exposed Filters doesn't seem to work here, CCK or not).

mattbk’s picture

Version: 6.x-2.x-dev » 7.x-3.0-rc1

This issue still exists in Views 7.x-3.0-rc1. An exposed filter of "NULL" or "NOT NULL" results in a text box, not a check box as it should.

Shevchuk’s picture

Version: 7.x-3.0-rc1 » 7.x-3.7

Still having this issue in 7.x-3.7. A temporary (well, this issue is 3.5 years old :D) workaround would be to add a boolean field to a content type, auto-set/unset it on node update (with Rules, Conditional Fields, hook_node_presave, etc.), and use that field for exposed filter.

UPD: Found #477984: CCK field is empty/not empty filter doesn't work when exposed, and comment #60 has a patch which does exactly what we all are looking for here =)

anrikun’s picture

Version: 7.x-3.7 » 7.x-3.x-dev
Issue summary: View changes
Status: Active » Needs work