Validation Not working

Hi all

Please any one tell me.why my ajax validation is not working in my form.

In view

In Controller

In Model

Any help will be highly appreciated

:mellow:

Seems like you marked required fields also as ‘safe’ (without validate), so just remove line in model:

array(‘msg_to,msg_subject,msg_message’, ‘safe’),

I also comment that line But still it is not working?


$model = new MessageCFmodel;

echo $_POST['ajax'];

if(isset($_POST['ajax']) && $_POST['ajax']==='msgform')

{

$model->attributes=$_POST['MessageCFmodel'];

//MessageCFmodel::validate();

$model->validate();

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

}

Replace with


$model = new MessageCFmodel;

if(isset($_POST['ajax']) && $_POST['ajax']==='msgform')

{

  $model->attributes=$_POST['MessageCFmodel'];

  echo CActiveForm::validate($model);

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

}

Hope it will solve your problem.