-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix required form radio/checkbox fields #1643
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few comments regarding changes.
@AnthonyLedesma Good for another review 👌 |
Confirmed this closes #1653. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are very close. The required attributes seem to be properly preventing form submission but we have a case where no errors are shown to the user. To replicate this bug use the following markup.
<!-- wp:coblocks/form -->
<!-- wp:coblocks/field-email {"required":true} /-->
<!-- wp:coblocks/field-radio {"required":true,"options":["Yes","No"]} /-->
<!-- wp:coblocks/field-checkbox {"required":true,"options":["Yes","No"]} /-->
<!-- wp:coblocks/field-textarea {"required":true} /-->
<!-- wp:coblocks/field-submit-button {"submitButtonText":"Contact Us"} /-->
<!-- /wp:coblocks/form -->
When you leave the radio options unchecked and fill all other form elements, we have a case where form fails to submit and no errors are shown to the user. There should be an error message here specifying that an option must be selected.
@AnthonyLedesma This was a bug with Go, setting the radio buttons to Feel free to pull down godaddy-wordpress/go#579 and test, or use a different theme. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confirmed that the bug reported was with Go.
Note
If using Go to test, this will require godaddy-wordpress/go#579
Description
Made sure that the checkboxes/radio fields of form block, when set to required, prevent the form from being submitted until at least one option/checkbox is selected.
Resolves #1517 and resolves #1653.
Note: HTML does not provide a way to require checkbox groups. The workaround was to enqueue a script and display a notice above the field when no checkboxes were checked.
The notice:
Please select at least one checkbox.
Wrapped in the filter:
coblocks_form_checkbox_required_text
Screenshots
Types of changes
Bug fix (non-breaking change which fixes an issue)
How has this been tested?
Manually
Checklist: