Field type: Boolean

When set non-required filter on the Boolean field the -Any- choice does not stick.

On loading/running the saved view (without any query params) it always shows True or Fallse; -Any-is available, but not selected by default as desired.

Next time open up the Views UI config for that filter it always shows one of True or False, never -Any- as previously.

Snippet from views Single item YAML export:

        field_d8_wishlist_value:
          id: field_d8_wishlist_value
          table: node__field_d8_wishlist
          field: field_d8_wishlist_value
          relationship: none
          group_type: group
          admin_label: ''
          operator: '='
          value: true
          group: 1
          exposed: true
          expose:
            operator_id: ''
            label: 'On Webel''s D8 Wishlist'
            description: ''
            use_operator: false
            operator: field_d8_wishlist_value_op
            identifier: field_d8_wishlist_value
            required: false
            remember: true
            multiple: false
            remember_roles:
              anonymous: anonymous
              authenticated: authenticated
              administrator: '0'
              author: '0'
              developer: '0'
          is_grouped: false

Note value: true although -Any was chosen and applied then view saved.

CommentFileSizeAuthor
#4 2712131.patch980 bytesmkalkbrenner

Comments

webel created an issue. See original summary.

dawehner’s picture

Component: views_ui.module » forms system

Thank you for reporting this issue! Small improvements matter!

After some hour of debugging that problem I figured out that \Drupal\Core\Render\Element\Radio::preRenderRadio seems to have a bug.
If you check out the HTML of the form correctly, you'll see that both the All and the False element is marked with checked="checked". This is caused by the following line
if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) { in this preRenderRadio method.

I think the right method would be to check whether the value is a boolean/integer, casts them to their type and then do a "===", but I'm not sure about the correct fix.

mkalkbrenner’s picture

Version: 8.1.0-rc1 » 8.4.x-dev

I just ran into this issue with the latest core and Search API. I exposed a filter on the boolean content translation outdated flag.

mkalkbrenner’s picture

Status: Active » Needs review
StatusFileSize
new980 bytes
mkalkbrenner’s picture

Status: Needs review » Needs work

The last submitted patch, 4: 2712131.patch, failed testing.

mkalkbrenner’s picture

Status: Needs work » Closed (duplicate)