alex-w
(Pr0j3ct A1ex)
1
I’ve got an ActiveForm with client validation enabled and want to submit it using ajaxSubmitButton();
The problem is the submit button will happily fire regardless of the state of validation.
I think a callable validate() function would be good (could only work for client side validation).
It would display any errors then return a boolean value indicating if the form is valid.
This would allow the use of beforeSend in the ajax button.
Hi
Did you find the solution for this ? If Yes can you plz plz plz post ?
hehbhehb
(Hehbhehb)
3
you can use afterValidate option.
<?php
Yii::app()->clientScript->registerScript(‘search’, "
function refresh_gridview(form, data, hasError)
{
if (!hasError) {
$.fn.yiiGridView.update('$gridview_id', {
data: $(form).serialize()
});
}
}
");
$form=$this->beginWidget('CActiveForm', array(
'action'=>Yii::app()->createUrl($this->route),
'id'=>'form_id',
'enableAjaxValidation'=>true,
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true,'afterValidate'=>'js:refresh_gridview'),
));
?>
…
afterValidate is not getting fired for me when I am using ajaxSubmitButton !
So I came up myself with the simplest solution to this problem here
http://www.yiiframework.com/forum/index.php/topic/37075-form-validation-with-ajaxsubmitbutton/