Closed (cannot reproduce)
Project:
Drupal core
Version:
9.3.x-dev
Component:
views.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Nov 2012 at 17:55 UTC
Updated:
3 Jul 2021 at 12:56 UTC
Jump to comment: Most recent, Most recent file

Comments
Comment #1
joachim commentedThe problem is in views_handler_filter_field_list:
This returns an array whose keys are 0 and 1 but whose values are empty.
Comment #2
joachim commentedIn FieldAPI, this is picked up by options_field_widget_form(), where options modules provides the form element for its widgets:
Which is a bit brittle, as it makes this a special case that list_allowed_values() doesn't actually know about.
We probably need a custom handler here for boolean fields to take care of this.
Comment #3
joachim commentedThe plot thickens somewhat...
The field settings have:
but the 'use field label for on value' is a widget setting, and hence is on the instance:
So it's possible for the field to have no display values for the checkbox, but not have the 'use field label for on value'. However, if you do that then your field widget looks totally broken, so I don't think it's a case we need to cater for.
Comment #4
dave reidMay be of help: http://drupal.org/project/boolean_formatter
Comment #5
dublutz commentedThis problem can be solved also by setting explicit values for On value and Off value in Boolean checkbox field configuration form. Values can be 1 and 0 but they need to be set.
Comment #6
joachim commentedClosing #1250794: 1 and 0 not visible when configuring boolean filter criteria as a duplicate. This is newer, but has more information about a potential fix.
Comment #7
joachim commentedHere's a patch.
Comment #8
star-szrJust ran into this, thanks @joachim. Patch works as expected. Does this need tests?
Comment #9
dawehnerThe only fun thing is to bring this into Drupal 8, contrib has to be pragmatic!
Committed and pushed to 7.x-3.x
It is great to see a patch from @joachim, and tested by @cottser
Comment #10
mpdonadioI'll tackle this.
Comment #11
mpdonadioOK, added field formatter. It works in Views. For some reason, though, the label shows up as 'node.field_the_machine_name' instead of the label in the formatter settings there. I am sure I am missing something silly here.
This will need an IS update and Beta Eval for D8. And tests updates to
Yay.
Comment #12
mpdonadioUnassigning myself. My availability the next two or three weeks may be spotty.
Comment #13
jhedstromThis adds tests. I don't think the
FieldBooleanTestis actually using the Field API, but I added alabeltest there nonetheless.Comment #14
jhedstromComment #16
jibranLet's do that as well. Other then that I think this is ready.
Comment #17
mpdonadioAddressed #16. Passes locally.
Had to rework the test a smidge. ->assertRaw() can't test for empty strings, and rather than add in a special case, I changed the test to get the rendered content and use ->assertIdentical(). However, because ->render() doesn't return a string, rather a SafeString, I added an explicit cast.
Not sure if it is worth it to file a followup about wrong @return types in KernelTestBase as it is deprecated in favor of the new one.
Comment #19
lendudeTrying to recreate the original issue in D8:
Boolean field doesn't have "Use field label instead of the "On value" as label" in D8
And the filter options in Views look like this for a boolean field:

So I don't think this issue actually exists in D8 (anymore?). It would be better if the filter value would use a select instead of a textfield, but that seems like a different issue.
Or am I missing some steps to reproduce this? This is with a minimal install with just Views, Views UI and Fields UI added.
Comment #22
mpdonadio#19, do you think our test-only patch is an invalid case then? I just retriggered retests of #17 to see what happens.
Comment #24
lendude@mpdonadio, I'm just saying that what appears to get fixed here has little or nothing to do with what's in the issue summary. So if this an issue that can be reproduced through the UI some steps to reproduce would be nice.
On to the actual patch.
Like you said in #11, the label still shows up as
node.field_the_machine_namein the 'Output format' selector. Would that also need a test?This test seems totally unrelated to this issue.
Comment #25
oenie commentedIt seems to me that current stable 8.0 version, there is something wrong with the formatter used by Views for the boolean type.
It has already been mentioned in another bug report as well: #2469553
Comment #26
oenie commentedAfter digging a little further, it seems what the old 'properties' of D7, now called base fields, are handled somewhat differently from custom Entity Fields.
The base field 'status' is added the correct filter of boolean in the switch statement in the function mapSingleFieldViewsData in core/modules/views/src/EntityViewsData.php. The code there is using the field type to determine the views configuration.
A newly created field of type boolean however, is processed in the function views_field_default_views_data in core/modules/views/views.views.inc. Unfortunately that code is using the db column type to decide on the views configuration for the field. Boolean fields are created as tiny int in the database, which ends in the fields getting incorrectly labeled as of the filter type 'numeric'.
Comment #29
mpdonadio#26, I think that is more part of the related issue you linked. I think this issue is diagnosed, and that we mainly need a Views maintainer to weigh in here (and to remove the bad hunk that creeped in). Triggered a re-test.
Comment #30
xjmThe patches in #17 do seem to show a bug that still needs fixing. The fail of the test-only patch is:
That sounds about right. I agree we should confirm the bug through the UI though before proceeding. There's also a few other things in the patch that would need to be cleaned up, like a
checkPlain()in there etc. https://www.drupal.org/node/2549395The core committers and Views maintainers (@alexpott, @effulgentsia, @xjm, @dawehner, @tim.plunkett) agreed that this does not need to be a major issue.
Comment #31
xjmHmm, actually it's not clear to me that the retests actually ran. In fact I think they did not. I'd suggest testing locally and re-uploading the patches if it turns out they still apply and work.
Comment #40
quietone commentedI tested this on 9.3.x and was not able to reproduce this error. See attached screenshot.
Therefore, closing as cannot reproduce. If you are experiencing this problem reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue (starting from "Install Drupal core").
Thanks!