I have 2 form type that display 2 selects
$builder
->add('control1', EntityType::class, [
'label' => 'Country',
'class' => Country::class,
])
->add('control2', EntityType::class, [
'label' => 'State',
'class' => State::class,
])
then in the twig template
{{ form_row(form.control1)}}
{{ form_row(form.control2)}}
How can I enable control2 only if a specific option is selected in control 1? thanks.
Dynamic Generation for Submitted Forms
The following example create a form with two fields,
countryandstate. Thestatefield depends on thecountryfield and will remain disabled with no choices available if no country has been selected.Form Type
Template