Hi all,
I’m new to Yii Framework. I would like to know is it possible to validate a field which value is generated from an ajax request. I have a ‘Code’ field which will trigger ajax request after input and on success it will fill in a ‘Level’ field. I have something like this on my form:
<?php echo $form->textField($model,'code', array(
'size'=>10,
'maxlength'=>10,
'ajax' => array(
'id'=>'code',
'type'=>'POST',
'url'=>Yii::app()->createUrl('master/check'),
'success'=>$model->addError('level','Error'),
),
)); ?>
In my case, the $model->addError function is called not after the ajax but right after the page is loaded. Any idea what went wrong?