$model->haserrors() not working fine

Hi there,

On my controller I am calling $model->hasErrors() and I expect that it should return some boolean value according to the validation errors in rules given by me.

But this method is returning no value I don’t know why ?

My code is like





    if($model->hasErrors()) {

 

            //  Print error code here  (I want this method as it is what I have written) 

    }

    else{


            $model->some_attribute_name = some_value;      // Even I want this method as it is what I have written

            $model->save();

    }               

                

 

Please help me out !!!

Thanks in advance

try to use


if($model->validate())

Thanks for the reply…

but still not working




if(!$model->validate())

 echo CHtml::errorSummary($model);




what output?