Problem updating data in CJuiDialog


I’m new to yii and I need some help, I’m trying to update data inside a CJuiDialog and ajax but it seems that the server doesn’t get back the POST data.

If i’m trying the same but put the CJuiDialog part comment out it’s work perfectly.

This is my code in the view file:


            if ($model->isNewRecord)


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



                            'title'=>'Select Category:',








                echo $form->label($model,'category');

                echo ": ";

                echo $form->dropDownList($model,'category',$model->getCategories(),array('class'=>'catName'));


                echo CHtml::ajaxSubmitButton(












        <h2 id="cat_name"></h2>

and this is the one in the Controller:

 public function actionUpdateCategory() 


            $model=new Article;




                echo CHtml::encode('Categroy: '.$model->categoryClass->name);              




Can someone help me with this one please?

Hi deadEnd, welcome to the forum.

I’m not really sure, but I think the problem is in the fact that you are using a form($form) that is in the outside the dialog.

I think the echo’ed lines inside a widget are buffered and will be put somewhere else (probably at the bottom of <body>). And the ajaxSubmitButton will be put outside the form. Check the html output.

Try create another form($form2) inside the dialog and use it.

Hi softark,

The html output looks fine (it puts the widget and the ajax button inside the <form>)

I tried to create another form inside the widget but it didn’t solve it, so I took the new form above the original one and it works.


My bad, it still doesn’t work. Because of the two forms when the second form submitted it doesn’t get the data from the first one.

There are some wiki articles about this:

  • update-delete-model-with-cjuidialog-works-in-cgridview

  • cjuidialog-and-ajaxsubmitbutton

  • cjuidialog-for-create-new-model

I prefer using an iframe, it works with a few steps:

  • cgridview-update-create-records-in-a-cjuidialog