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.
When a required element in a multi-page form is hidden due to the value of an element from a previous page, the user cannot navigate out of the page which contains the hidden/required field. This was working properly in 5.0-beta24 AFAIK.
Use the following YAML code to reproduce:
step_1:
'#type': wizard_page
'#title': 'Step 1'
my_checkbox:
'#type': checkbox
'#title': 'My Checkbox'
'#description': 'Check this to reveal a required field in Step 2. If you don't check this you will be stuck at Step 2.'
step_2:
'#type': wizard_page
'#title': 'Step 2'
my_number:
'#type': number
'#title': 'My Number'
'#required': true
'#states':
visible:
':input[name="my_checkbox"]':
checked: true
'#default_value': '1'
'#min': '1'
step_3:
'#type': wizard_page
'#title': 'Step 3'
actions:
'#type': webform_actions
'#title': 'Submit button(s)'
Comment | File | Size | Author |
---|---|---|---|
#6 | 2937501-6.patch | 1.58 KB | jrockowitz |
| |||
#4 | webform.webform.issue_2937501.yml | 3.63 KB | jrockowitz |
Comments
Comment #2
nodecode CreditAttribution: nodecode commentedI can confirm that this was indeed working properly as of 5.0-beta25
Comment #3
nodecode CreditAttribution: nodecode commentedWhat's even worse, I tried to reproduce the error with a fresh install of 5.0-rc1 at simplytest.me and got a 500 Internal Server Error!
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI am seeing the below fatal error when there is a hidden required element.
Attached is the webform I am using for testing.
@nodecode Thanks for including such a great example.
Comment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedBelow is the change that caused this regression.
#2929796: Hidden field validation on min/max length
Comment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #7
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI committed the patch. Please download the latest dev release to review.
Comment #9
nodecode CreditAttribution: nodecode commentedThanks! Looks fixed to me :)