I’m trying to call ajax validation when submit button pressed. Form should be sent via ajax, so i’m using the next code:
Dialog:
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
'id'=>'create',
'options'=>array(
'title'=>'New',
'autoOpen'=>false,
'modal'=>true,
'buttons'=>array('Send'=>'
$("#test-form").ajaxSubmit({
success: function(data) {
$("#create").dialog("close");
},
dataType: "json"
});
'),
),
));
$this->render('test/_form', array('model' => $model));
$this->endWidget('zii.widgets.jui.CJuiDialog');
and form:
<?php
$form = $this->beginWidget('CActiveForm', array(
'id' => 'test-form',
'action'=> CHtml::normalizeUrl(array('test/create')),
'enableAjaxValidation' => true,
'clientOptions' => array(
'validateOnSubmit'=>true,
)
));
...
When submit button is pressed no validation occurred.
I tried use line $.fn.yiiactiveform.validate("#test-form", function(a){console.log(a);}, function(a){console.log(a)});
but it’s not working.
I need to call default yii ajax validator using js. Now this validator called when i set ‘validateOnChange’=>true. But i need to call it in my JS.