- Issue created by @Grimreaper
- Merge request !512Issue #3472513 by grimreaper: Radios/checkboxes: Allow to access label attributes → (Open) created by Grimreaper
- Issue was unassigned.
- Status changed to Needs review
2 months ago 8:24am 6 September 2024 - 🇮🇳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.
- 🇫🇷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.