I’m trying to use client side validation on a form displayed with a CJuiDialog.
The widget is created as usual :
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id' => 'TPDialog',
'options' => array('autoOpen' => false,'modal' => 'true'),
));
echo $this->renderPartial('//thirdParty/_ajaxForm', array(
'model' => new ThirdParty(),
'action' => $this->createUrl('thirdParty/asyncCreate'),
));
$this->endWidget('zii.widgets.jui.CJuiDialog');
So is the form :
$form = $this->beginWidget('CActiveForm', array(
'id' => 'third-party-form',
'enableClientValidation' => true,
));
echo $form->errorSummary($model);
[here we renders the rows...]
?>
<div class="row buttons">
<?php echo CHtml::submitButton('Go !'); ?>
</div>
<?php $this->endWidget(); ?>
and in the related model object, validation rules are set to accept client side validation :
public function rules() {
return array(
array('name', 'required', "enableClientValidation" => true),
array('name', 'length', 'max' => 45),
array('name', 'safe', 'on' => 'search'),
);
}
Now, I expect the client side validation to prevent any calls to the server as long as the form is not client side validated. Here, if my unique field ‘name’ is empty, I should see the error message and that’s all.
Unfortunately, the server is called all the time and the actionAsyncCreate() is always triggered, even if the field is empty.
What am I missing here ?