Hi All,
In my form I have dependant dropdown list which does ajax request and adds more elements to the form.
The dropdown code looks like -
<div class="row">
<?php echo $form->labelEx($model,'type'); ?>
<?php echo $form->dropDownList($model,'type', Globals::getTypes(),
array(
'ajax' => array(
'type' => 'POST',
'url' => Yii::app()->controller->createUrl('getFields'),
'update' => '#fields',
)
)
); ?>
<?php echo $form->error($model,'type'); ?>
</div>
The action code is -
public function actionGetFields() {
$type = $_POST['MyTypes']['type'];
$typeModelName = Globals::getTypeModelName($type);
if(!$typeModelName)
Yii::app()->end();
$typeModel = new $typeModelName;
$this->renderPartial('_getFields', array('model'=>$typeModel), false, true);
Yii::app()->end();
}
My _getFields view looks like this -
<div class="row">
<?php echo CHtml::activeLabel($model,'key'); ?>
<?php echo CHtml::activeTextField($model,'key',array('size'=>60,'maxlength'=>128)); ?>
</div>
<div class="row">
<?php echo CHtml::activeLabel($model,'txn'); ?>
<?php echo CHtml::activeTextField($model,'txn',array('size'=>60,'maxlength'=>128)); ?>
</div>
My whole setup works really fine, except I am not able to validate the fields in _getFields view page.
Please let me know how can I add validation for partially rendered view in errorSummary() of main view and also individual filed should show the error message.
I tried something like this for individual fields -
<?php echo CActiveForm::error($model,'txn'); ?>
but got the error like
Thanks Already,
Sachin.