Creating record via Input CJuiDialog

hello guys

I am basically trying to put the create page of my model expense on zii.widgets.jui.CJuiDialog and trying to save it through the JuiDialog. I successfully put the create page but not able to save it.

After clicking the save button the JuiDialog box closed and nothing happened. Ajax validation is also not working in the JuiDialog box.

Plz point the mistakes am doin

here is the code


<?php /* Input dialog with Javascript callback */

    $this->beginWidget('zii.widgets.jui.CJuiDialog', array(

        'id'=>'mydialog2',

        'options'=>array(

            'title'=>'Create Expense',

			'width'=>600,

			'height'=>600,

            'autoOpen'=>false,

            'modal'=>true,

        ),

    ));

	$model=new Expense;

	echo $this->renderPartial('/expense/_form', array('model'=>$model));


    $this->endWidget('zii.widgets.jui.CJuiDialog');


    echo CHtml::link('open dialog', '#', array(

            'onclick'=>'$("#mydialog2").dialog("open"); return false;',

    ));

?>

You need to set in the action of the controller to save the values as

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

// process the model and save the values after that return something(no required) to says that All is Done correctly

}

ajax validation is not working when I am opening it in juidialog box. How to resolve this?? And I think I am not getting the value set by post after clicking the save button on the form inside juidialog box.

ajax validation is not working when I am opening it in juidialog box. How to resolve this?? And I think I am not getting the value set by post after clicking the save button on the form inside juidialog box.

Here is my code that I am using for creating Values using JUIDialog




	public function actionCreate()

	{

		$model=new FeatureVarients;

                if(isset($_GET['feature_id'])){

                    $model->feature_id=$_GET['feature_id'];

                }

		// Uncomment the following line if AJAX validation is needed

		// $this->performAjaxValidation($model);


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

		{

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

			if($model->save()){

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

                {

                    echo CJSON::encode(array(

                        'status'=>'success', 

                        'div'=>"Item Added"

                        ));

                    exit;               

                }

                else                      

				$this->redirect(array('/administration/features/view','id'=>$model->feature_id));

                        }

		}


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

        {

           Yii::app()->clientscript->scriptMap['jquery.js'] = false;

            echo CJSON::encode(array(

                'status'=>'failure', 

                'div'=>$this->renderPartial('_form', array('model'=>$model), true)));

            exit;               

        }

        else{                

                

		$this->render('create',array(

			'model'=>$model,

		));

        }

	}