Preview of a form

Can someone tell me how to create preview of a form without saving it inside database.

Write now i am using a method which is not at all a gud option…

anyway my controller file…


public function actionSignup()

{

    $model=new PtEmpInfo('register');


    if(isset($_POST['ajax']) && $_POST['ajax']==='pt-emp-info-signup-form')

    {

        echo CActiveForm::validate($model);

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

    }


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

    {

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

     

	 	$valid=$model->validate();

  

		

		if($valid)

        

		{

	

		//preview part


		$arremp = array($_POST['PtEmpInfo']['EMP_NAME'],$_POST['PtEmpInfo']['EMP_CONTACT_NAME'],$_POST['PtEmpInfo']['EMP_DESIGNATION']);

		

		

	$_SESSION['arr']=$arremp;

		

		$this->redirect("index.php?r=site/page&view=preview");

		

		

        }

    }

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

}

my view code


<div class="form">


<?php 

session_start();

$data=$_SESSION['arr'];

?>

<div class="column">

<?php

echo"Company Name<br/>";

echo"Contact Name<br/>";

echo"Designation<br/>";

.

.

.

?>

</div>

<div class="row">

<?php

echo ":".$data[0]."<br/>";

echo ":".$data[1]."<br/>";

echo ":".$data[2]."<br/>";

echo ":".$data[3]."<br/>";

.

.

.


?>

</div>


</div>

One approach is to use one and the same action but in that action check if $_POST[‘Preview’] (given your preview button’s name=Preview) is initiated and if it is only echo the content else save() in DB…

Keep your form in a subview that you can renderPartial with each logic and just have some area to display the temp content should the user click on preview button.

I am sure there are other solutions but this one seems quite simple to start with…

hope this helps

Sorry i din understand… can u pls pls help through some code??