Recently i have been working on Yii 2 for one of my clients. The application relies heavily on Ajax for loading different components and forms. Since there were forms, I had to use validation as well.
Yii 2 has made validation very simple. The server side validation worked perfectly, almost out of the box. I also had to add client side validation and despite everything being in order, the forms were not showing validation errors on input change.
So, all that is needed to make client side validation work on an ajax loaded page is to enable client validation like so:
$form = ActiveForm::begin([
'id' => 'contact-form',
'enableClientValidation' => true,
And then rendering the form view like so:
Latest posts by alexey (see all)
- Fixing a WordPress pagination 404 error - June 1, 2017
- Making Yii 2 Client side validation work - April 22, 2017
- Angular 2 : Sending requests with cache control headers - January 25, 2017