[solved] Ajax Validation not working (CActiveForm)

Yii 1.1.3

Webapp created using yiic tool

I am testing using the generated Contact Form.

/site/contact.php:


<div class="form">


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

    'id'=>'contact-form',

    'enableAjaxValidation'=>true,

)); ?>


[form fields]


<?php $this->endWidget(); ?>


</div><!-- form -->

SiteController.php:


public function actionContact()

{

	$model=new ContactForm;

		

	// Uncomment the following line if AJAX validation is needed

	$this->performAjaxValidation($model);

		

	if(isset($_POST['ContactForm']))

	{

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

			

		if($model->validate())

		{

			...

		}

		

		$this->render('contact', array('model'=>$model));

	}

	

	protected function performAjaxValidation($model)

	{

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

		{

			echo CActiveForm::validate($model);

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

		}

	}

}

I have not modified ContactForm model. Normal validation is working fine.

jquery.js is included but yiiactiveform.js is not being included for some reason. I have not disabled it anywhere.

EDIT: I got my answer - I had removed $form->error() from my input fields.

Thank you.I have spend a lot of time to resolve it;

The easiest errors are always hardest to find! :] Glad, you found it after all.

This should be somewhere explain in very clear manners how this AJAX VALIDATION WORKS…

Especially $form->error() Hint…

Thanks