Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Feature request
Issue priority Normal
Prioritized changes Usability and sites builder experience improvement
Disruption None, no BC breaks or migration concerns

Note: The bug in the original post is no longer an issue so this is technically a feature request. Though the reason the bug was reported is likely because they missed the "Use field label" option, which this issue is now trying to remedy.

Problem/Motivation

When you have a Boolean field within a Content Type, you must define a Field label (e.g., a question to be answered "Yes" or "No"), and a label for each of the two possible answers (On/Off, Yes/No, True/False, etc.). Optionally, you can define some help text.


This is what it would look like to the end user if we had a Field with "Owns a car?" as label, with "Yes" and "No" as On/Off labels.

When the site manager later wants to use add Content of said Content Type, the Boolean field is shown as a checkbox with the "On" value's label, and the help text. However, the Field label and the "Off" value label are not shown. Thus, the site manager doesn't know what question this Boolean field is answering, unless specified on the help text.


This is the field info.


This is what the site manager sees when trying to add content.

Proposed resolution

Edit the Add Content form so that the Field label for Boolean Fields is also shown.

Remaining tasks

User interface changes

Edit the Add Content form so that the Field label for Boolean Fields is also shown.

API changes

Replication Steps

1. Go to Manage -> Structure -> Content types.
2. Manage fields for a content type.
3. Add a Field of type Boolean.
4. Label it with a Yes/No question (Does this person smoke?).
5. Set the "On" and "Off" labels to any value.
6. Go to Content.
7. Add Content of the type we just added a Boolean Field to.

You will see the checkbox with the "On" label, but not the question (the Field label), so you don't know what the field is answering (unless specified in the help text).

Original report by @R. Volk

// I didn't found an similar issue, so i created this one. Please close if duplicated or already fixed in newer versions.

Boolean fields has no labels in the node edit form.

1. edit a content type
2. create a boolean field "Bug"
3. use "Yes" and "No" as labels
4. open the node edit page, you will finde a single checkbox with "Yes" besides, but you don't know what yes means

[x] Yes

instead of:

Bug:
[x] Yes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Version: 8.0.0-beta1 » 8.0.x-dev

... please always report and test against 8.0.x-dev Thank you!

Anonymous’s picture

I could reproduce the issue, and made a test that demontrates the lack of the label. However, I'm not sure what the correct behaviour should be (not showing a label is default for checkboxes).

Anonymous’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: missing_label_for-2361469-2.patch, failed testing.

geffio’s picture

Shreya Shetty’s picture

Assigned: Unassigned » Shreya Shetty
Shreya Shetty’s picture

Assigned: Shreya Shetty » Unassigned
Anonymous’s picture

@Geffio: There is a difference when editing a form (your screenshot 1) or looking at a node (your schreenshot 2). If you look at the promotion options in the edit form, you'll see they also don't have a label. That's what makes me hesitate what the intended behaviour on a form is.

Shreya Shetty’s picture

Status: Needs work » Needs review
FileSize
1003 bytes
1003 bytes

Hi R. Volk ,
I have made changes as guided by you.Please review and tell if further improvements have to be made.

Shreya Shetty’s picture

swentel’s picture

IIRC, you should be able to set the label on the manage form display. I think we should probably make that as the default.
As far as I can see the patch is make exceptions in the base field edit form, we should look at the widget for booleans instead.
That's in BooleanCheckboxWidget and maybe we should set 'display_label' to TRUE by default.

Andres Mejia’s picture

I am taking some screenshots to illustrate the complete procedure using Boolean fields.

Anonymous’s picture

Status: Needs review » Needs work
Andres Mejia’s picture

Issue tags: +D8UX usability, +LatinAmerica2015
FileSize
106.45 KB
123.78 KB

I managed to compose 2 mockups for better analysis.

Andres Mejia’s picture

Issue summary: View changes

option a
option b

Andres Mejia’s picture

FileSize
97.22 KB
106.58 KB

This is my proposal on how the functionality should work, since it provides a more usable.

option c
option d

ariadni-sofia’s picture

Assigned: Unassigned » ariadni-sofia

You could use the radio button option instead of checkbox. In this way you will have 2 boxes with yes/no, on/off option
i hope to help you

ariadni-sofia’s picture

Assigned: ariadni-sofia » Unassigned
mikeker’s picture

Assigned: Unassigned » mikeker

I agree with @swentel in #11 -- the default for the single on/off widget should be to use the field label instead of the "On label." That will reduce confusion when adding new Boolean fields as that's how most existing Boolean fields are configured (eg: Promoted to front page).

However I don't agree with the proposal in #16. I don't see why the field label should be repeated as in the second screenshot.

mikeker’s picture

Assigned: mikeker » Unassigned
Status: Needs work » Needs review
Issue tags: -boolean, -fields
FileSize
3.02 KB

Different approach to that taken with earlier patch so no interdiff. This changes the default value of the Use field label instead of the "On label" as label option from FALSE to TRUE and adjust the tests accordingly.

On a sidenote, I think "Use field label instead of the "On label" as label" is in the running for most confusing sentence in Drupal... :)

mikeker’s picture

Issue summary: View changes

Added beta eval and note just above issue summary.

mikeker’s picture

Title: Missing label for boolean fields » Single on/off checkboxes should "Use field label" by default

Better describes what is happening.

mikeker’s picture

Patch still applies cleanly.

mikeker’s picture

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

jhedstrom’s picture

Issue tags: +Needs usability review

The patch in #25 still applies (with fuzz). I manually tested and it works as expected, and much improves the default behavior for adding a single checkbox. The approach taken is that suggested in #11. Tagging for UX review.

yoroy’s picture

Version: 8.1.x-dev » 8.2.x-dev
Issue tags: -D8UX usability, -Needs usability review +Usability

Enough fuzz in the patch for simplytest to reject it, so couldn't test manually. From reading the issue and looking at the screenshots this makes a lot of sense: it removes confusion by providing a better default. Win!

Not rtbc'ing because I don't know if we should present core committers fuzzy patches :)

jhedstrom’s picture

Issue tags: +Needs reroll

Could somebody reroll so we don't present the committers with fuzz? :)

mikeker’s picture

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

I think this is now safe to RTBC.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 30: 2361469-30-boolean-field-settings.patch, failed testing.

mikeker’s picture

Status: Needs work » Needs review

I think the failure is unrelated.... Retesting.

yoroy’s picture

Status: Needs review » Reviewed & tested by the community
xjm’s picture

Category: Bug report » Task
Status: Reviewed & tested by the community » Fixed

I tested this both with and without the patch, and I definitely agree that the default being added by the patch makes the most sense. What's more, all the default config that ships with core already uses this setting, which also points to it being a more useful default. The updates to the test coverage also look good, and we have signoffs from both usability and field maintainers.

I also tested and confirmed that when one switches the widget to radio buttons, that still uses the yes/no labels as expected, and that switching back to a single checkbox afterward also goes back to the new default.

One concern I did have is that with this default we would have the reverse problem. When the site builder sets up the field and enters "On" and "Off" labels without changing the form display, the first time they create the content, it seems like the "On" and "Off" labels don't do anything. But then they will still see them by default as soon as they save the content, so that is fine.

I checked to confirm that we did not need to update any default config for this setting, and there is no change to the schema because it is a default value. So there is no need for an update path. (Obviously, we can't change fields on sites that are already installed because site owners will have configured that on purpose as well. The same is true for migrations, and I confirmed that this setting does have a migration already; see #2260239: D6->D8 Profile field (checkbox)).

Committed a1529fe and pushed to 8.2.x. Thanks!

  • xjm committed a1529fe on 8.2.x
    Issue #2361469 by mikeker, Shreya Shetty, pjonckiere, Andres Mejia,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.