Closed (duplicate)
Project:
Views (for Drupal 7)
Version:
7.x-3.7
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
24 Jun 2013 at 21:38 UTC
Updated:
29 Aug 2013 at 16:54 UTC
Jump to comment: Most recent file
Comments
Comment #1
dfletcher commentedRan into this myself, was going to post an issue but found yours and decided since I was not the only one seeing this to dig deeper.
Not quite sure this is the best way to fix this but here's an attempt.
Trouble is that views_handler_filter_field_list handles all fields in a generic uniform way using the core API function list_allowed_values(). In the case of a boolean value, these "allowed values" are boolean TRUE and FALSE. When PHP tries to display TRUE and FALSE as a string, it outputs blank nothing (PHP quirk).
So my patch just says "if there is $this->value_options[0] and $this->value_options[1] but the value is empty, put "True" and "False".
Another approach might be to actually detect if the field data type is boolean and act on that. Other suggestions?
Comment #2
dfletcher commentedOkay so I'm really not happy with my solution in the first patch. There could be some other legitimate reason that value is present but empty (actual allowed value of empty string). I'm leaning toward "detect boolean field, do special jiggery for it".
Comment #3
merlinofchaos commentedHonestly, I think this is actually a problem with the checkbox field more than Views, which should have sane default. As such, that's how we should consider addressing it: either fixing checkbox field to be sane, or putting a shim in and admitting that checkboxes are broken in this instance.
Comment #4
dfletcher commentedMight actually have a reasonable fix for this in core, we'll see how well it goes. Idea is to put defaults in the boolean values fields so that our use case of "making a boolean field as a Views toggle switch" is less clumsy.
Fix here: For boolean with empty values, list_allowed_values() should return array('0', '1')
Edit: oh and I was wrong about the PHP quirk. Turns out it was just that the defaults are currently intentionally blank.
Comment #5
jim0203 commentedSorry guys, I think I shouldn't have created this issue in the first place. Seems like it's already being dealt with as a core issue at https://drupal.org/node/1750950
Comment #6
dfletcher commentedThat's great thanks Jim, nice find. Looks like it's even scheduled to be backported, perfect.
Comment #7
leoklein commentedStill, saved my butt (for the moment). I had a boolean field in D7 for a event calendar/map:
Views just wouldn't pick up it as a filter (not that it's a Views problem). That was a bummer since I already had about 500 events. The patch helped. Thanks.