Problem/Motivation
Steps to reproduce
1. Create a webform with radios, checkbox, checkboxes elements
2. Create a required textfield or another (use this to generate error)
2. Go to webform settings and remove client-side validation
3. Submit test form submission with some checkboxes checked, radios selected
4. Note that the values submitted for radios and checkboxes are not rendered
Proposed resolution
Update preprocessing of checkboxes to use `#value` rather than `#default_value`.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|
Issue fork civictheme-3495607
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
dhruv.mittal commentedWorking on it
Comment #3
richardgaunt commentedHi @dhruv.mittal,
Pull requests for this project are done on this repository via GitHub: https://github.com/civictheme/monorepo-drupal
There are three parts to this solution:
Update the civictheme_preprocess_fieldset__form_element__civictheme_field__checkboxes and civictheme_preprocess_fieldset__form_element__civictheme_field__radios
In `civictheme_preprocess_fieldset__form_element__civictheme_field__checkboxes`:
We need to change this line:
https://github.com/civictheme/monorepo-drupal/blob/develop/web/themes/co...
And
https://github.com/civictheme/monorepo-drupal/blob/develop/web/themes/co...
to check for `#value` rather than `#default_value`
Update the checkbox preprocessing
We need to change the checkbox preprocessing at: https://github.com/civictheme/monorepo-drupal/blob/develop/web/themes/co... to something like this
Add some behat tests
We need to add some tests ensuring that in error forms retain their values for checkboxes and radios
Comment #5
dhruv.mittal commentedHI @richardgaunt,
I have done the all the suggested changes.
But I don't know about behat tests, I would love to help if you guide me about them.
Comment #6
richardgaunt commented@dhruv.mittal Could you create the PR from a forked https://github.com/civictheme/monorepo-drupal this way I can review and merge there. Changes from github get pushed up to this repository.
I can review and have behat tests added there.
Comment #7
dhruv.mittal commentedI have created the pr for the same please review
https://github.com/civictheme/monorepo-drupal/pull/1319
Comment #8
richardgaunt commentedComment #10
dhruv.mittal commented@richardgaunt thanks for merging the MR, could you please change the issue status to "FIXED".
Comment #11
fionamorrison23 commented@dhruv.mittal we will update the status after this work has been tested. Thanks for your contribution.
Comment #12
fionamorrison23 commentedComment #13
fionamorrison23 commentedComment #15
fionamorrison23 commentedComment #16
danielgry commentedVerified and tested on 1.x-dev
Testing Results:
1. Checkboxes and radio inputs retain their selected state after form validation errors
2. Inspected the checkbox input and confirmed the checked attribute is correctly present before data-drupal-selector
Screenshot:

Comment #17
danielgry commentedAdding screenshot as part of comment above:

Comment #18
danielgry commentedComment #19
danielgry commentedComment #20
fionamorrison23 commentedComment #21
richardgaunt commentedComment #22
fionamorrison23 commentedComment #23
fionamorrison23 commented