Yii Validation On Html

Hi all,

I’m creating forms and I realize that when I use $form->field($model,$attribute), there will be yii validation. But when I use Html::activeTextInput, there are no validation. What I have to do now to enable validation on Html class?

Thanks

you need to show the errors by yourself:


<?= Html::error($model, 'username') ?>

If you want server side validation … you can display it as errors in form error summary or call Html::error to generate messages.

Client side attribute validation of yii active form however would not work by default. If you would need this, you should use $form->field. An alternative (not tested) could be to embed your Html::activeTextInput in between something like ActiveField::begin() and ActiveField::end().

Thanks so much, I’ll test it.