Problem With Cactiveform.aftervalidade

I’m trying to use afterValidade of CActiveForm and it doesn’t seems to work. I made this code =>

_form.php




<?php

/* @var $this Itens_EmprestimoController */

/* @var $Itens_Emprestimo Itens_Emprestimo */

/* @var $form CActiveForm */


$js=<<<EOD

js:function(form, data, hasError) {

   alert('after');

   return false;		

}

EOD;

$js1=<<<EOD

js:function(form) {

   alert('before');

   return true;

}

EOD;


?>




<div class="form">


<?php $form=$this->beginWidget('CActiveForm', array(

	'id'=>'itens--emprestimo-form',

	'enableAjaxValidation'=>true,

	'clientOptions'=>array('validateOnSubmit'=>true,

                             'afterValidade'=>$js,

                             'beforeValidate'=>$js1))); ?>

 ...



I first trying to made an ajax request in afterValidade, but it doesn’t work then

i made this code to test afterValidade, beforeValidade works but afterValidade not.

I enable the performAjaxValidation in controller.

I use yii 1.1.12

Dear Friend

Kindly check after correcting this.




'clientOptions'=>array('validateOnSubmit'=>true,

                             'afterValidade'=>$js,           //afterValidate

                             'beforeValidate'=>$js1))); 



hi there is a problem with your heredoc I changed your js function to following and its working just try it




<?php 

  $js="js:function(form, data, hasError) { alert('after'); return false; }"; 

  $js1="js:function(form) { alert('before'); return true; }"; 

   ?> 

thanks people… I change to afterValidate and it works (sorry, my error)