Fix/337 optional label radio checkbox#344
Open
marek7gol wants to merge 2 commits intolocalgovdrupal:2.xfrom
Open
Fix/337 optional label radio checkbox#344marek7gol wants to merge 2 commits intolocalgovdrupal:2.xfrom
marek7gol wants to merge 2 commits intolocalgovdrupal:2.xfrom
Conversation
Remove the --form-item-required-pseudocontent and --form-item-optional-pseudocontent variables from variables.css file and their references from the forms.css file.
Author
|
Hi @danchamp, @markconroy, @msayoung 👋 |
Contributor
|
@markconroy would you able to take a look at this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #337 - Webform item labelling not working for radio/checkbox groups.
This PR replaces the CSS-based approach for displaying "(optional)" labels with PHP preprocess functions, which provide more reliable and consistent behaviour across all form element types.
Problem
The existing CSS-based solution using
--form-item-optional-pseudocontenthad several issues:Solution
This PR implements two PHP preprocess functions that handle the "(optional)" label logic:
localgov_microsites_base_preprocess_fieldset()Appends "(optional)" to the fieldset legend for supported element types:
radios,checkboxes,webform_uk_address,webform_address. Only applies when the fieldset (parent element) is not required and has a legend title.localgov_microsites_base_preprocess_form_element()Appends "(optional)" to standalone (not being a part of a fieldset/parent element) form element labels. Supported types:
checkbox,radio,textfield,textarea,email,tel,number,url,date,datetime,select. Detects if a radio/checkbox is part of a fieldset/parent element (by checking#array_parentsdepth) and skips individual labels in that case, as the legend already displays the "(optional)" text.Changes
localgov_microsites_base.themefile.--form-item-required-pseudocontentand--form-item-optional-pseudocontentCSS variables fromcss/base/variables.cssfile.css/components/forms.cssfile.