Filtering a view by a checkbox field-Collection of common programming errors
My site has a node type called “Resource”. This node type has a field called “Reviewed”; this field is a single on-off checkbox:
I’ve created a view that lists all of the nodes of node-type “Resource”. I’d like to filter that view so it only displays nodes that have the “Reviewed” checkbox checked. However, when I try to add that field to my view, I’m shown the following:
I would expect the “Options” select box to be a checkbox that I could either check or leave empty. Instead, I’m given a select box with “Select all” in it. Whether I select this or not, I’m then presented with an error message saying that there are “No valid values found on filter: Content: Reviewed.”:
I’ve tried the “exposing the master display trick” at http://technology.blue-bag.com/top-tip-drupal-views-no-valid-values-found-filter, but that hasn’t worked: there’s no “unknown” filter in the master display, so there doesn’t appear to be anything to fix.
Any idea as to how I can achieve the result I’m looking for? And what’s the deal with the strange UI with the select box rather than a checkbox? Would be good to know if there’s some logic to it; if not, I’ll post an issue to the appropriate drupal.org issue queue.
-
this is some sort of a bug / incosistency of how the boolean field is made. if you leave it in default, without any 0 / 1 values, it wont show them in places like this filter. But : the values are there 🙂 under “Select all” you have 2 rows that just dont have captions. When you pick one of them, you can see that the SQL for your view is changed.
The workaround would be to add some captions to the values in the field defintion.
Originally posted 2013-11-09 22:40:38.