Ajax Contact Form

I’m trying to convert the standard Yii Contact Form into an Ajax form. So basically if the submit button is pressed the whole page should not load.

I tried the following in the view and it did not work




<?php 


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

	 'id'=>'contact-form',

	'enableAjaxValidation'=>true,

));


?>



My controller looks as follows


public function actionContact()

	{

		$model=new ContactForm;

		$content = $model->getContactContent(2);

		

	

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

		{

			

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

			if($model->validate())

			{

				$headers="From: {$model->email}\r\nReply-To: {$model->email}";

				mail(Yii::app()->params['adminEmail'],$model->subject,$model->body,$headers);

				

				Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.');

				$this->refresh();

			}

			

		}

		if(Yii::app()->request->isAjaxRequest){

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

		}else{

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

		}

	}



What is the best approach to do this

http://www.yiiframework.com/forum/index.php?/topic/6665-help-test-the-new-widget-cactiveform/page__st__40

last post you will find the answer