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.
Page 1 of 1
public validate method for activeform
#2
Posted 08 October 2012 - 06:56 AM
alex-w, on 05 April 2011 - 07:29 AM, said:
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.
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 ?
#3
Posted 09 October 2012 - 06:33 AM
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'),
));
?>
...
<?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'),
));
?>
...
#4
Posted 03 November 2012 - 07:29 AM
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.yiiframew...axsubmitbutton/
So I came up myself with the simplest solution to this problem here
http://www.yiiframew...axsubmitbutton/
Share this topic:
Page 1 of 1

Help














