Form rendered using ajax:
<?php $form = ActiveForm::begin(['id' => 'que',
'enableClientValidation' => true
]); ?>
<?php echo $form->field($model, 'fk_subject')
->dropDownList(ArrayHelper::map($subjects, 'id_subject', 'name'), [
'class' => 'form-control ng-pristine ng-valid ng-touched',
'ng-model' => 'que.fk_subject',
'prompt' => 'Select subject',
'ng-change' => 'fillTopic(que);'
]); ?>
<?php echo $form->field($model, 'fk_topic')
->dropDownList([], [
'class' => 'form-control ng-pristine ng-valid ng-touched',
'ng-model' => 'que.fk_topic',
'prompt' => 'Select topic',
'ng-change' => 'openAddTopic(que);',
'ng-options' => 'topic.id_subject as topic.name for topic in topics',
]); ?>
<?php echo $form->field($model, 'type')
->dropDownList($questionTypes, [
'class' => 'form-control ng-pristine ng-valid ng-touched',
'prompt' => 'Select question type',
'ng-model' => 'que.type',
'ng-change' => 'addAnswerOptions(que);',
]); ?>
<?php echo Html::submitButton('Save',
['class' => 'btn btn-primary',
'name' => 'Save']) ?>
<?php ActiveForm::end(); ?>
I loaded the above form using ajax in yii2 and problem is client side validation is not working with it. If I load the form content on window load it works fine.