Moving Default Contact form to index.php

I’m trying to move the yii generated contact form to index.php. I pretty much copy and pasted the code from the contact.php view file to index.php and added the action parameter to the active form widget. When I try to run the site it says $model is undefined. What am I missing? Or is there a better or different way to approach this?

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







)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>



in the controller, model variable is passed to the view in the contact action, like


what you need to do is to do the same on the index action

I think it got it to work by moving the actionContact method code into actionIndex. This should work if I remove the action parameter from the active form widget, right? Or do I need to change the action parameter to ‘site/index’

public function actionIndex()


	// renders the view file 'protected/views/site/index.php'

	// using the default layout 'protected/views/layouts/main.php'


        $model=new ContactForm;






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


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





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


yep, both ways should work



thanks for the help.