Answer the question
In order to leave comments, you need to log in
How to make Validation work in Yii2?
Why if you insert a form in the form
$form->field($model, 'user')->widget(Select2::classname(), []);
echo Select2::widget(['model' => $model, 'attribute' => 'user',]);
Answer the question
In order to leave comments, you need to log in
Describing a field via $form->field(), the process goes through ActiveField, which generates a valid HTML structure from the point of view of client-side validation. Otherwise, the HTML code looks different, and the standard client-side validation cannot work correctly.
By examining the client validation code, you can understand what elements it expects, and by substituting them, you can make the code work. For example, these are the selectors of the fields themselves, the container selectors (filed-*), the selectors of the error placement block.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question