On my form there are certain fields that are required and/or visible depending on which country the user selects.

If Country = "United States" Then
State is visible and required,
Region/Province is not visible,
Zip/Postal Code is required.

Else Country is not "United States" Then
State is not visible nor required,
Region/Province is visible (but optional),
Zip/Postal Code is optional.

I tested the issue in a development environment using Drupal core 8.6.9 and Webform 8.x-5.2-beta1 and it still does not work.

The form is in production at https://naturalhistory.si.edu/research/anthropology/collections-and-arch... (Drupal core 8.6.7 and Webform 8.x-5.0-rc24).

I read through some of the other reports and I am not using Bootstrap. I also find the same problem regardless of what browser I use.

CommentFileSizeAuthor
webform-cofiguration.yml18.94 KBkochertj
webform-source.yml9.71 KBkochertj

Comments

kochertj created an issue. See original summary.

jrockowitz’s picture

Status: Active » Needs review

The custom 'name' #attribute needs to be removed from 'resvis_country'. It is literally changing the name of the select menu which is breaking all the conditional logic.

You need to change…

resvis_country:
  '#type': select
  '#title': Country
  '#description_display': invisible
  '#options': country_names
  '#required': true
  '#required_error': 'Please select your country from the country pull-down menu.'
  '#default_value': 'United States'
  '#attributes':
    name: country

…to…

resvis_country:
  '#type': select
  '#title': Country
  '#description_display': invisible
  '#options': country_names
  '#required': true
  '#required_error': 'Please select your country from the country pull-down menu.'
  '#default_value': 'United States'
jrockowitz’s picture

Status: Needs review » Closed (works as designed)
kochertj’s picture

Thank you.