$model->validate() throwing error

I’ve copied the “contact” form from the blog demo site into my application and when i submit it without all of the required fields populated, the app errors out.

Code from the controller:




public function actionContact()

{

	$model=new ContactForm;

	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();

		}

	}

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

}



Model rules:




	public function rules()

	{

		return array(

			// name, email, subject and body are required

			array('name, email, subject, body', 'required'),

			// email has to be a valid email address

			array('email', 'email'),

			// verifyCode needs to be entered correctly

			array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),

		);

	}



Is there some sort of app config required in order to enable form validation?

I’ve got to be missing something very basic… HELP!

Thanks!

Can you display thrown error ??