Custom Validation Not Working

Hi All

i am trying to implement custom validation for fields, but looks like the function is not called in the rule. can any please help out.

4489

test.txt

public function rules()

{


	


	return array(


		


		array('WeekHoursContribution','cust'),		


		


	);


}

public function cust($attribute, $params)

{

echo "function working";

    //  $this->addError($attribute, 'Either additional details or Resume is required.');

}

Hi

Put your code in your action view


if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')

                {

                        echo CActiveForm::validate($model);

                        Yii::app()->end();

                }

hope it’s help…

thanks for the reply… :) i will try it and get back to you

Hi

Also check this link

http://help.discretelogix.com/php/yii/how-to-create-custom-validation-rule.htm

Hope you understand basic idea how it’s work.

hi

i am doing the buildin validations they are working fine.

but with custom validation i am not getting the results.

i tried with if(isset($_POST[‘ajax’]) && $_POST[‘ajax’]===‘login-form’)

            {


                    echo CActiveForm::validate($model);


                    Yii::app()->end();


            }

its not wrking…