How To Renderpartial A Form Within A View With Action?

Hi there, I need to render partial contact form in the layout main file. I am able to render it but when i enter data it does not goes into the the action. It works fine independently. I have set the action url for the form but it is still not working.

Here is my code for view contact form


<?php  

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

                    'id' => 'contact-form',

                    'enableClientValidation' => true,

                    'clientOptions' => array(

                        'validateOnSubmit' => true,

                        'action' => Ccontroller::createUrl('/site/contact'),

                    ),

                        ));

                ?>





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


                <div class="row-fluid">

                    <div class="left span5">

                        <?php echo $form->labelEx($model, 'name'); ?>

                        <?php echo $form->textField($model, 'name', array('class' => 'span12 left')); ?>

                        <?php echo $form->error($model, 'name'); ?>

                    </div>

                    <div class="left space-left span5">

                        <?php echo $form->labelEx($model, 'email'); ?>

                        <?php echo $form->textField($model, 'email', array('class' => 'span12 left')); ?>

                        <?php echo $form->error($model, 'email'); ?>

                    </div>

                </div>                


                <div class="row-fluid">

                    <?php echo $form->labelEx($model, 'subject'); ?>

                    <?php echo $form->textField($model, 'subject', array('class' => 'span10 left', 'size' => 60, 'maxlength' => 128)); ?>

                    <?php echo $form->error($model, 'subject', array('class' => 'left', 'style' => 'color:red')); ?>

                </div>


                <div class="row">

                    <label>Text</label>

                    <?php echo $form->textArea($model, 'body', array('class' => 'span5 left', 'rows' => 6, 'cols' => 50)); ?>

                    <?php echo $form->error($model, 'body', array('class' => 'left', 'style' => 'color:red')); ?>

                </div>


                <?php if (CCaptcha::checkRequirements()): ?>

                    <div class="row">

                        <?php echo $form->labelEx($model, 'verifyCode'); ?>

                        <div class="left span3 clear-left">

                            <?php $this->widget('CCaptcha'); ?><br/>

                            <?php echo $form->textField($model, 'verifyCode'); ?>

                        </div>

                        <div class=" hint left space-left span2">Please enter the letters as they are shown in the image above.

                            <br/><strong>Letters are not case-sensitive</strong>.</div>

                        <?php echo $form->error($model, 'verifyCode'); ?>

                    </div>

                <?php endif; ?>


                <div class="row buttons">                    

                    <?php

                    $this->widget('bootstrap.widgets.TbButton', array(

                        'label' => 'Submit',

                        'type' => 'danger',

                        'block' => false,

                        'buttonType' => 'submit',

                        'size' => 'small'

                    ));

                    ?>

                </div>


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

I have rendered partial in my main.php file. Here is my controller actionContact


public function actionContact()

	{

		$model=new ContactForm;

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

		{

                    

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

			if($model->validate())

			{

                           

				$name='=?UTF-8?B?'.base64_encode($model->name).'?=';

				$subject='=?UTF-8?B?'.base64_encode($model->subject).'?=';

				$headers="From: $name <{$model->email}>\r\n".

					"Reply-To: {$model->email}\r\n".

					"MIME-Version: 1.0\r\n".

					"Content-type: text/plain; charset=UTF-8";


				mail(Yii::app()->params['adminEmail'],$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,'source'=>'null'));

	}

When i searched related articles i found that to make a widget is the solution but when i studied widget in yii i found that it is mainly for presentational purposes. So i decided not to go with that. But my above code is not working. How to do that? thanks

You got ajax validation enabled (validateOnSubmit) but the required logic is missing in the action. Instead, it processes the form and refreshes the page. That is sent as an ajax response so the yii active form prevents submitting as it is not detecting successful server side validation. So the effect should be that the form IS processed, but your page does not reload.