After trigger checkboxes require message(client-side validation), next submmit will not trigger its next required field's mandatory message.
Steps to reproduce:
- Create required checkboxes and required other fieils for form, this is my form source below.
- Click Submit for the first time, trigger checboxes's mandatory message, the display is normal.
- Check the non-first option of checkboxes, then click submit buttom, its next required field's mandatory message will not be triggered.(I think it should be triggered)
test_checkboxes:
'#type': checkboxes
'#title': 'Test Checkboxes'
'#description_display': invisible
'#options':
A: OptionA
B: OptionB
P: Others
'#required': true
'#required_error': 'Please select your option.'
test:
'#type': textfield
'#title': test
'#required': true
test_select:
'#type': select
'#title': Type
'#title_display': invisible
'#description_display': invisible
'#options':
A: optionA
B: optionB
C: optionC
'#empty_option': 'Test Type'
'#required': true
'#required_error': 'Please select Type.'| Comment | File | Size | Author |
|---|---|---|---|
| #32 | 3209439-33.patch | 1.38 KB | jrockowitz |
| #26 | 3209439-26.patch | 1.08 KB | jrockowitz |
| #25 | 3209439.gif | 3.78 MB | paulocs |
| #20 | fixed_wf.gif | 1.82 MB | guilhermevp |
| #20 | chrome-capture (2).gif | 2.41 MB | guilhermevp |
Comments
Comment #2
Omega_yang commentedComment #3
Omega_yang commentedComment #4
Omega_yang commentedComment #5
Omega_yang commentedComment #6
Omega_yang commentedAfter verification, this issue also exist in latest version of webform(6.0.2).
Due to execute setCustomValidity() after click submit trigger 'invalid' function, first Submit set custom validity, second submit clear custom validity.
I think can add setCustomValidity function to click function.(Please correct me if it is wrong, thanks.)
Comment #7
Omega_yang commentedComment #8
avpadernoComment #9
Omega_yang commentedComment #10
jrockowitz commentedComment #11
paulocsPatch can't be applied to the 8.x-5.x branch.
Comment #12
jrockowitz commentedThe attached webform replicates the awkwardness of the checkboxes' clientside validation.
Comment #13
jrockowitz commentedThe attached patch improves the UX by hiding the error message when any checkbox is checked.
This patch probably needs so additional work for checkboxes with other, check all, or check none options
Comment #14
jrockowitz commentedComment #15
paulocsHello!
I'm trying to test it, but my message errors look different.
I have
webform_clientside_validationmodule and its requirements installed.See in the image I attached how the errors are displayed. Do I need to enable any other module?
I imported webform #12 and I'm using webform 8.x-5.x.
Ps: I didn't apply patch #13.
Comment #16
jrockowitz commentedWhat Drupal version and base theme are you using?
In the webform_clientside_validation there is some JS to address the error message placement issue.
@see webform/modules/webform_clientside_validation/js/webform_clientside_validation.ife.js
Comment #17
paulocsI have a fresh drupal 8.9.14 version installed and I'm using Bartik as theme.
I notice that
webform_clientside_validation.ife.jsis loaded if inline_form_errors is installed, so I enabled but it didn't resolve the problem.I'll let someone else review this issue and see if I can figure out what is going on.
I attached a image that shows my problem after I installed inline_form_errors.
Comment #18
jrockowitz commentedAre any errors being logged in the browser's JS console:?
Comment #19
paulocsNothing related to it.
Comment #20
guilhermevp commentedI was able to reproduce the error the same way @jrockowitz showed in comment #12, and patch fix it for me. Not moving to RTBC due to further discussion from #15.
Comment #21
jrockowitz commentedWe need to the know the steps required to reproduce the issue from #15
Comment #22
paulocsI'm getting in contact with @guilhermevp to see if I'm missing something.
Feel free to fix the issue as #15 is maybe not related to this issue scope.
I'll keep you updated.
Cheers, Paulo.
Comment #23
paulocsWe found the problem. The thing is that I was using clientside_validation 3.0.x and not clientside_validation 3.0.0-rc4.
After I checked out 3.0.0-rc4 tag I was able to see the message in the right place.
This issue that affected it: https://www.drupal.org/project/clientside_validation/issues/3208810
Thanks!
Comment #24
jrockowitz commentedIs this RTBC?
Comment #25
paulocsNo, I found a bug. Steps to reproduce:
1) Check the first option
2) Check the last option
3) Unchecked the first option
4) Unchecked the last option
5) The error message is not displayed.
I added a gif.
Comment #26
jrockowitz commentedThe issue is the first option has an event handler set via the clientside validation module which is also hiding the error message.
I am not sure we are going to find a perfect solution.
The attached patch removes the error when any checkbox is checked. The first checkbox can retriggers the disease of error message.
Comment #27
jrockowitz commentedComment #29
jrockowitz commentedComment #30
paulocsYeah, I tried this approach locally but I didn't add any patch because IMHO #13 is better because it triggers something when the user doesn't select anything.
Comment #31
paulocsPatch #13:
1) Check the first option
2) Check the last option
3) Unchecked the first option
4) Unchecked the last option
5) The error message is not displayed but the icon is.
Patch #26:
1) Check the first option
2) Check the last option
3) Unchecked the first option
4) Unchecked the last option
5) Nothing is triggered.
Comment #32
jrockowitz commentedThis patch includes a workaround.
Comment #33
paulocsLooks good!
Comment #35
jrockowitz commented