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)
- WordPress stuck on a “Too many redirects” error loop when using SSL - January 17, 2018
- Sails.js + Passport.js : req.user undefined - December 31, 2017
- “Could not open input file” on running migrations in yii2 - October 27, 2017