Radios/checkboxes: Allow to access label attributes

Created on 6 September 2024, 4 months ago

Problem/Motivation

When using a radios or checkboxes element, in the "advanced" section, the "label attributes" is hidden when "Wrapper type and attributes > Wrapper type" is not set to "Form element".

I don't understand why it is a requirement to set label attributes.

I want to be able to reproduce https://getbootstrap.com/docs/5.3/forms/layout/#horizontal-form with https://www.drupal.org/project/ui_suite_bootstrap and this currently blocks me.

Steps to reproduce

Add a radios elements and try to set label attributes.

Proposed resolution

Remove the state and processing preventing usage of label attributes with fieldset wrapper.

Remaining tasks

- Provide MR
- Code review
- Merge

User interface changes

Label attributes accessible every time.

Feature request
Status

Active

Version

6.2

Component

Code

Created by

🇫🇷France Grimreaper France 🇫🇷

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Grimreaper
  • 🇫🇷France Grimreaper France 🇫🇷
  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • 🇫🇷France Grimreaper France 🇫🇷
  • Pipeline finished with Failed
    4 months ago
    Total: 1979s
    #275474
  • 🇫🇷France Grimreaper France 🇫🇷

    Patch for Composer usage.

  • 🇮🇳India bebalachandra

    Verified the issue in drupal 10.2.x with webform version 6.2.x-dev.

    Steps followed to reproduce the issue:
    1. Install drupal 10.2.x version.
    2. Install webform module version 6.2.x-dev.
    3. Navigate to admin > structure > webform.
    4. You will find existing webform named "contact". also we can configure new webform by clicking on "add webform"
    5. I have verified by editing existing webform "contact"
    6. Click on the "build" button located right side of the "contact" webform.
    7. Click on "add element"
    8. Search for "radios" or "checkbox".
    9. click on "add element" right next to the element.
    10. configuration window will open, navigate to advanced tab.
    11. After the patch/ MR you will see "label attributes" is visible by default.
    12. Before the patch/MR "label attributes" is visible only when "Wrapper type and attributes > Wrapper type" is set to "Form element".

    MR!512 and #5 patch solves the issue reported here.

    Hence I suggest to move this to RTBC

    Attached screen recordings for reference.

  • 🇺🇸United States jrockowitz Brooklyn, NY

    The '#label_attributes' are only applicable when using a form element, radios and checkboxes are wrapped in a fieldset by default.

    The attached webform shows that the label attributes are only display via the form element.

    I think we need to leave things AS-IS and not expose '#label_attributes' that when they are not displayed.

  • Pipeline finished with Success
    3 months ago
    Total: 210s
    #298221
  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    @jrockowitz, thanks for the webform config example which helps to discuss.

    radios and checkboxes are wrapped in a fieldset by default.

    Yes.

    The '#label_attributes' are only applicable when using a form element,

    Then in the case of radios and checkboxes, '#label_attributes' should be used to control the legend.attributes.

    This is something that Core does not currently do, but I think it should.

    I did it in https://git.drupalcode.org/project/ui_suite_bootstrap/-/blob/5.0.x/src/H..., because some design systems (in my case Bootstrap 5), allow or may allow to put radios/checkboxes into a fieldset, like Core does but needs to apply some classes to handle cases like horizontal alignment in https://getbootstrap.com/docs/5.3/forms/layout/#horizontal-form

    Those options are in the "Advanced" tab, so I think we can consider that people using those options know what they are doing. At least, if I put '#label_attributes' in the "Custom settings / Custom properties" because I know what I am doing with my theme, it should not be removed.

  • 🇺🇸United States jrockowitz Brooklyn, NY

    I see no easy solution. This feels like an edge case that will cause an issue if we expose label attributes on checkboxes and radios, and it does not do anything.

  • 🇫🇷France Grimreaper France 🇫🇷

    Hi,

    Then let's do nothing about the "#states", but as mentioned in my previous comment:

    At least, if I put '#label_attributes' in the "Custom settings / Custom properties" because I know what I am doing with my theme, it should not be removed.

Production build 0.71.5 2024