Required attribute missing for confirm_email with states

Created on 7 February 2025, about 1 month ago

Problem/Motivation

I've created an webform with an email_confirm field which is only visible based on states. The field is required so if the field is visible based on the states, the field should be required. It's working for an email field but not for email_confirm

Steps to reproduce

I've created a dummy contact form in a new Drupal 10.4.2 website. Enabled the webform_clientside_validation.

name:
  '#title': 'Your Name'
  '#type': textfield
  '#required': true
  '#default_value': '[current-user:display-name]'
subject:
  '#title': Subject
  '#type': textfield
  '#required': true
  '#test': 'Testing contact webform from [site:name]'
message:
  '#title': Message
  '#type': textarea
  '#required': true
  '#test': 'Please ignore this email.'
email_confirm_without_states:
  '#type': email_confirm
  '#title': 'Email confirm without states'
  '#required': true
check_confirm:
  '#type': checkbox
  '#title': 'Check confirm'
email:
  '#type': email
  '#title': 'Your Email'
  '#required': true
  '#states':
    visible:
      ':input[name="check_confirm"]':
        checked: true
  '#default_value': '[current-user:mail]'
email_confirm:
  '#type': email_confirm
  '#title': 'Email confirm'
  '#required': true
  '#states':
    visible:
      ':input[name="check_confirm"]':
        checked: true
actions:
  '#type': webform_actions
  '#title': 'Submit button(s)'
  '#submit__label': 'Send message'

- Go to the form and click on submit
- You get error warnings ad the visible fields. Including email_confirm_without_states
- Click the checkbox to show the other email_confirm (hidden by states)
- Click on submit
- No error labels at the email_confirm

🐛 Bug report
Status

Active

Version

6.2

Component

Code

Created by

🇳🇱Netherlands erwinvb

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024