Updating Yii Dropdownlist After Insert New Element [SOLVED] <p>I'm totally new in Yii, so, excuse me if the answer for this question is a little bit trivial.</p> <p>Here's my code: </p> <pre><code>&lt;p&gt; &lt;?php echo $form-&gt;labelEx($model,'phone_type'); ?&gt; &lt;span class="field"&gt; &lt;?php echo $form-&gt;dropDownList($model,'phone_type', CHtml::listData(PhonesTypes::model()-&gt;findAll(), 'id','type' )); ?&gt; &lt;?php echo $form-&gt;error($model,'phone_type'); ?&gt; &lt;/span&gt; &lt;/p&gt; </code></pre> <p>There will be a button to register new Phone types. So, after the submition of the form, that will be inside of a CJUiDialog, I wish that the above dropDownList be updated with the new type, without refresh the page. </p> <p>I google it a lot, but i only find things related to "dependent dropdowns" in Yii.</p> <p>What's the better approach to solve this problem? Is there something like <code>$.fn.cgridview.update</code>?</p> <p>Here's the Dialog code:</p> <pre><code>&lt;?php $this-&gt;endWidget('zii.widgets.jui.CJuiDialog'); $this-&gt;beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=&gt;'dialog-crud', 'options'=&gt;array( 'title'=&gt;'Create new Phone Type', 'autoOpen'=&gt;false, 'modal'=&gt;true, 'width'=&gt;1080, 'height'=&gt;820, 'resizable'=&gt;false ), )); ?&gt; &lt;iframe src="http://myapp/phone_types/create" width="100%" height="100%"&gt;&lt;/iframe&gt; &lt;?php $this-&gt;endWidget(); ?&gt; </code></pre> <p>And the code of the controller, is a trivial create function:</p> <pre><code>public function actionCreate(){ $model = new PhoneType; if(isset($_POST['PhoneType'])){ $model-&gt;attributes = $_POST['PhoneType']; if( $model-&gt;save() ){ //----&gt; some suggestion here? echo CHtml::script(""); Yii::app()-&gt;end(); } } } </code></pre> <hr> <p><strong>So, below is the code of my solution.</strong> In the view: </p> <pre><code>&lt;?php $this-&gt;beginWidget('zii.widgets.jui.CJuiDialog', array( 'id'=&gt;'dialog', 'options'=&gt;array( 'title'=&gt;'Phone Types', 'autoOpen'=&gt;false, 'modal'=&gt;true, 'width'=&gt;1080, 'height'=&gt;820, 'resizable'=&gt;false ), )); ?&gt; &lt;iframe src="phoneTypes/create" id="cru-frame" width="100%" height="100%"&gt;&lt;/iframe&gt; &lt;?php $this-&gt;endWidget(); ?&gt; </code></pre> <p>In my PhoneTypesController:</p> <pre><code>public function actionCreate(){ $model = new PhoneTypes; if(isset($_POST['PhoneTypes'])){ $model-&gt;attributes = $_POST['PhoneTypes']; if($model-&gt;save()){ echo CHtml::script(" window.parent.$('#dialog').dialog('close'); window.parent.$('#Phone_types_id').append('&lt;option value=".$model-&gt;id." &gt;'+'".$model-&gt;type."'+'&lt;/option&gt;'); "); Yii::app()-&gt;end(); } } $this-&gt;render('create',array( 'model'=&gt;$model, )); } </code></pre> <p>Thanks for your help!</p>