[#States API] Basic Address field inherits wizard page's #states

Created on 9 February 2021, almost 4 years ago
Updated 8 April 2024, 7 months ago

Problem/Motivation

On multi-page forms, Basic Address fields that are positioned inside pages with #states settings inherit the page's states:

<input data-drupal-selector="edit-basic-address-address" type="text" id="edit-basic-address-address" name="basic_address[address]" value="" size="60" maxlength="255" class="form-text form-item__textfield" data-drupal-states="{&quot;required&quot;:{&quot;.webform-submission-webform-error-add-form :input[name=\u0022should_we_show_page_two\u0022]&quot;:{&quot;checked&quot;:true}}}">

Since the field that serves as the source of the state is on a previous page, the Basic Address' subfields never get set to required.

Steps to reproduce

YAML:

page_1:
  '#type': wizard_page
  '#title': 'Page One'
  should_we_show_page_two:
    '#type': checkbox
    '#title': 'Should we show page two?'
    '#description': 'Check this box to move on to page two.'
    '#required': true
page_2:
  '#type': wizard_page
  '#title': 'Page Two'
  '#open': true
  '#states':
    visible:
      ':input[name="should_we_show_page_two"]':
        checked: true
  '#states_clear': false
  basic_address:
    '#type': webform_address
    '#title': 'Basic Address'
    '#description': 'The subfields on this Basic Address block are set to be required, but instead are inheriting the conditional #states settings from the Page element for their required settings.&nbsp; Because the checkbox is on the previous page, none of the fields are actually required.'
    '#address__required': true
    '#address_2__required': true
    '#city__required': true
    '#state_province__required': true
    '#postal_code__required': true
    '#country__access': false

Proposed resolution

Basic Address subfields should reflect their own requirement settings regardless of parent container's states.

πŸ› Bug report
Status

Needs work

Version

6.2

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States JI_Gravityworks

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024