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)'
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nodecode created an issue. See original summary.

nodecode’s picture

I can confirm that this was indeed working properly as of 5.0-beta25

nodecode’s picture

What'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!

jrockowitz’s picture

Status: Active » Needs work
FileSize
3.63 KB

I am seeing the below fatal error when there is a hidden required element.

Fatal error: Maximum function nesting level of '1000' reached, aborting! in /private/var/www/sites/d8_webform/core/lib/Drupal/Core/Form/FormState.php on line 1148

Attached is the webform I am using for testing.

@nodecode Thanks for including such a great example.

jrockowitz’s picture

Below is the change that caused this regression.

#2929796: Hidden field validation on min/max length

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
1.58 KB
jrockowitz’s picture

Priority: Normal » Critical
Status: Needs review » Fixed

I committed the patch. Please download the latest dev release to review.

  • jrockowitz committed 0f9c711 on 8.x-5.x
    Issue #2937501 by jrockowitz: Multi-page form breaks when required...
nodecode’s picture

Thanks! Looks fixed to me :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.