Client side validation for dynamically created forms

I see that Yii2 RC has improved its forms implementation, particularly for dynamically created forms.

What I’ve done is create an edit form that is generated via pjax. However, when generating the form this way, client side validation is broken. I know others have this issue, but I haven’t found a good solution for it yet. I am hoping the improvements in RC will be able to address this particular challenge.

In the link below, there is some description on how to perform validation for dynamically created fields, but I can’t say I fully understand the example.

http://www.yiiframework.com/news/80/yii-2-0-rc-is-released/

Here is the editProf view that is rendered via pjax:




<?php


use yii\helpers\Html;

use yii\widgets\ActiveForm;


?>


<div class="col-lg-5">

    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']],['id' => 'editpro']); ?>


    <?= $form->field($prof, 'location') ?>

    <?= $form->field($prof, 'description')->textarea() ?>


    <p><b>Profile Photo</b></p>

    <?= Html::img('@web/' . $prof->photo_location, ['width' => '200px', 'height' => '200px']) ?>

    <br>

    <br>

    <?= $form->field($photo, 'file')->fileInput()->label(false) ?>


    <?= Html::submitButton('Save', ['class' => 'btn btn-primary', 'name' => 'save-profile']) ?>


    <?php ActiveForm::end(); ?>

</div>

How would I "inject" code for client-side validation for this form and what exactly would the code be?

For example, ‘location’ is limited to 25 characters and ‘file’ is limited to ‘.jpg, .gif’ extensions. What would be the code for this and where exactly would I put it (controller, model, view)?