I have a webform that's basically set up like this:
select:
'#type': select
'#title': 'Select Type'
'#options':
A: A
B: B
C: C
'#required': true
select_1:
'#type': select
'#title': 'Select 1'
'#options':
'Yes': 'Yes'
'No': 'No'
'#required': true
container:
'#type': container
'#states':
visible:
':input[name="select_1"]':
value: 'Yes'
select_2:
'#type': select
'#title': 'Select 2'
'#options':
'Yes': 'Yes'
'No': 'No'
'#states':
invisible:
- ':input[name="select"]':
value: A
- or
- ':input[name="select"]':
value: C
'#required': true
container_01:
'#type': container
'#states':
visible:
':input[name="select_2"]':
value: 'Yes'
text_2:
'#type': textfield
'#title': 'Text 2'
'#required': trueThere's a select box with a few types, a select box to open a container, a select box in that container that may be hidden depending on the type chosen in the first select box, and a container that opens if this inside select box is set to yes. The inside select box will be hidden if the type is A or C. All fields are required.
When I set my type to A and the first select box to Yes, it properly hides the inside select box and doesn't show the inside container.
But clicking submit does nothing and instead gives an error in console:
An invalid form control with name='select_2' is not focusable.
The requirement on the inside select (named select_2 here) should some how be disabled if its hidden so the form can submit properly.
| Comment | File | Size | Author |
|---|---|---|---|
| #10 | webform.webform.not_focusable_text_fields.yml | 7.21 KB | esod |
| #6 | confirm_form_states.zip | 4.8 KB | esod |
| #5 | form_control_not_focusable.yml | 5.16 KB | esod |
| #3 | webform.webform.issue_3269776.yml | 4.97 KB | jrockowitz |
Comments
Comment #2
dsdeiz commentedI am getting the same error as well:
The error appears when you select "No" from the "Test" field. The error is:
Same error happens when you either set the element as "Required" or have it dynamically set as "Required" using conditions (automatically marking the element as "Required").
Comment #3
jrockowitz commentedI was able to replicate this issue using the attached webform.
This issue does not occur if you are using the clientside_validation.module.
The issue is related to #state API marking the hidden (display:none via CKEditor) textarea as required.
I am not seeing an easy fix for this issue.
Comment #4
jrockowitz commentedComment #5
esod commentedI'm able to to replicate this issue too. Select 'Recuse' in the attached form.
Comment #6
esod commentedI was hoping this wasn't just a webform problem, but it is a webform problem.
Comment #7
nilesh.addweb commented@esod It works with Plain text format. I think it having problem with ckeditor.
In first webform issue, I have resolved by updating select_2 states
Comment #8
liam morlandComment #9
esod commented@nilesh.addweb Yes, it works with plain text format or a textarea, which is also plain text. We'd like this to work using a CKEditor 5 text_format element.
Comment #10
esod commentedThis form uses only textfield, radio elements and #states.
Open the Console on your browser.
Select 'I am the nominee.'
Fill out the form.
Click Submit.
See the 'An invalid form control...' error.
Open the Console on your browser.
Select 'I am submitting on behalf of the nominee.'
Fill out the form.
Click Submit.
The form submits.
Comment #11
jrockowitz commentedFor #10, you have two required conditions (
submitter_information: visibleandsubmitter_middle_name: required) that are conflicting. Note thatsubmitter_information: visiblesets required conditions on the subelements.Your code
To fix this, you need to make the below change, which ensures both conditions for requiring
submitter_middle_nameare defined as expected.Comment #12
jrockowitz commentedThe original example seems to have the same nested condition issue as #10
Comment #13
jrockowitz commentedI am realizing that this ticket has multiple conditional logic issues being mentioned, and it makes it very difficult to resolve any of them.
The original issue can be solved by ensuring a container's conditions are applied to the subelements that have additional conditional logic.
Please open new tickets for the other issues mentioned.