Answer the question
In order to leave comments, you need to log in
How to validate multiple dropDownList?
Good afternoon.
There are three forms on the site page, each of which has two dropDownLIsts for selecting cities.
All forms for one model.
$form = ActiveForm::begin([
'id' => 'calcTopForm',
'enableAjaxValidation' => true,
]);
/***************/
$form->field($model, 'from')->dropDownList(RoutesCities::getAutocompleteList(),[
'prompt'=> 'Выбрать...',
])->label(false)
/*************/
$form->field($model, 'to')->dropDownList(RoutesCities::getAutocompleteList(),[
'prompt'=> 'Выбрать...',
])->label(false)
$this->render()
<?= $this->render('includes/calc-form', ['model' => $model]) ?>
Answer the question
In order to leave comments, you need to log in
Make a codepen and what styles do not work, what is at the bottom itself?
The solution turned out to be very simple.
Lost sight of what can be passed as the id parameter of the form. Now, when connecting the form in different parts of the file, I pass the form id as a parameter and the validation works on all lists.
and in the form itself I specify this id
$form = ActiveForm::begin([
'id' => $idForm,
'enableAjaxValidation' => true,
]);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question