Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Conditional required doesn't work properly with novalidate attribute
Steps to reproduce:
1. Create a webform with a radios type element with "Yes/No" options
2. Create a textarea element which will be required if "Yes" is selected
3. Disable client-side validation at Form Behaviors
4. Visit the form select "Yes" and try to submit
This is source (YAML), also an entire configuration is provided
yes_or_no:
'#type': radios
'#title': 'Yes or No'
'#options': yes_no
conditional_field:
'#type': textarea
'#title': 'Conditional field'
'#states':
required:
':input[name="yes_or_no"]':
value: 'Yes'
Comment | File | Size | Author |
---|---|---|---|
webform.webform.test_no_client_validation.yml | 2.57 KB | javivf |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz at The Big Blue House commentedConditional required elements only work using clientside validation because Webform 8.x-5.x is using Drupal's #states API.
@see #2807571: [meta] Webform 4.x features currently missing from the YAML Form module