{"id":764,"date":"2022-08-30T15:06:47","date_gmt":"2022-08-30T15:06:47","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/filtering-a-view-by-a-checkbox-field-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:06:47","modified_gmt":"2022-08-30T15:06:47","slug":"filtering-a-view-by-a-checkbox-field-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/filtering-a-view-by-a-checkbox-field-collection-of-common-programming-errors\/","title":{"rendered":"Filtering a view by a checkbox field-Collection of common programming errors"},"content":{"rendered":"<p>My site has a node type called &#8220;Resource&#8221;. This node type has a field called &#8220;Reviewed&#8221;; this field is a single on-off checkbox:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/HGp1J.png\" \/><\/p>\n<p>I&#8217;ve created a view that lists all of the nodes of node-type &#8220;Resource&#8221;. I&#8217;d like to filter that view so it only displays nodes that have the &#8220;Reviewed&#8221; checkbox checked. However, when I try to add that field to my view, I&#8217;m shown the following:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/e83sD.png\" \/><\/p>\n<p>I would expect the &#8220;Options&#8221; select box to be a checkbox that I could either check or leave empty. Instead, I&#8217;m given a select box with &#8220;Select all&#8221; in it. Whether I select this or not, I&#8217;m then presented with an error message saying that there are &#8220;No valid values found on filter: Content: Reviewed.&#8221;:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/0ghBi.png\" \/><\/p>\n<p>I&#8217;ve tried the &#8220;exposing the master display trick&#8221; at http:\/\/technology.blue-bag.com\/top-tip-drupal-views-no-valid-values-found-filter, but that hasn&#8217;t worked: there&#8217;s no &#8220;unknown&#8221; filter in the master display, so there doesn&#8217;t appear to be anything to fix.<\/p>\n<p>Any idea as to how I can achieve the result I&#8217;m looking for? And what&#8217;s the deal with the strange UI with the select box rather than a checkbox? Would be good to know if there&#8217;s some logic to it; if not, I&#8217;ll post an issue to the appropriate drupal.org issue queue.<\/p>\n<ol>\n<li>\n<p>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 \ud83d\ude42 under &#8220;Select all&#8221; 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.<\/p>\n<p>The workaround would be to add some captions to the values in the field defintion.<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-11-09 22:40:38. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>My site has a node type called &#8220;Resource&#8221;. This node type has a field called &#8220;Reviewed&#8221;; this field is a single on-off checkbox: I&#8217;ve created a view that lists all of the nodes of node-type &#8220;Resource&#8221;. I&#8217;d like to filter that view so it only displays nodes that have the &#8220;Reviewed&#8221; checkbox checked. However, when [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-764","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/764","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=764"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/764\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}