dubby
(Damien)
June 3, 2013, 5:36am
1
I’m wondering whether it’s possible to add a success catch when CActiveForm successfully validates.
For example with the following code:
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'enableAjaxValidation' => true,
'enableClientValidation' => false,
'focus' => array($model, 'username'),
'clientOptions' => array(
'validateOnSubmit' => true,
'validateOnChange'=>false,
'beforeValidate'=>'js:function(){$("#registration-form").parent().addClass("loading");return true;}',
'afterValidate'=>'js:function(){$("#registration-form").parent().removeClass("loading");return true;}',
'success'=>'js:function(){alert("trying");}',
),
'htmlOptions' => array(
'class' => 'form registration-forms',
'id' => 'registration-form',
)
)
);
?>
In this example I’m using TbActiveForm instead of CActiveForm but in either case the success is not called when the form fields are all valid. Is it possible to catch this n the Javascript? Does the responding JSON from the controller require something in order to do this? I don’t want the page to reload in this case.
Dubby
Hi,
Try to give the function name and check
‘clientOptions’ => array(
'validateOnSubmit' => true,
'validateOnChange' => false,
'afterValidateAttribute' => 'js:yourfunction1()',
'afterValidate' => 'js:yourfunction2()',
),
dubby:
I’m wondering whether it’s possible to add a success catch when CActiveForm successfully validates.
For example with the following code:
<?php
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'enableAjaxValidation' => true,
'enableClientValidation' => false,
'focus' => array($model, 'username'),
'clientOptions' => array(
'validateOnSubmit' => true,
'validateOnChange'=>false,
'beforeValidate'=>'js:function(){$("#registration-form").parent().addClass("loading");return true;}',
'afterValidate'=>'js:function(){$("#registration-form").parent().removeClass("loading");return true;}',
'success'=>'js:function(){alert("trying");}',
),
'htmlOptions' => array(
'class' => 'form registration-forms',
'id' => 'registration-form',
)
)
);
?>
In this example I’m using TbActiveForm instead of CActiveForm but in either case the success is not called when the form fields are all valid. Is it possible to catch this n the Javascript? Does the responding JSON from the controller require something in order to do this? I don’t want the page to reload in this case.
Dubby
dubby
(Damien)
June 3, 2013, 7:07am
3
kumarkulandai:
Hi,
Try to give the function name and check
‘clientOptions’ => array(
'validateOnSubmit' => true,
'validateOnChange' => false,
'afterValidateAttribute' => 'js:yourfunction1()',
'afterValidate' => 'js:yourfunction2()',
),
I could do that but it would give me the same result. I want to catch the event that the submitted form is VALID.