why i can't get the value by a textfield within CJuiDialog

I have something like this in one of my view files :




<?php 

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

	'id'=>'page-form',

	'enableAjaxValidation'=>false,

)); 





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

    'id'=>'addData',

    'options'=>array(

		'modal'=>true,

        'title'=>'Add Data',

        'autoOpen'=>false,

        'height'=>600,

        'width'=>750,

        'show'=>'fade',

        'hide'=>'fade',

    ),

));

		

     echo $form->textField($model,'username',array('size'=>50,'maxlength'=>50)); 

	

$this->endWidget();


<div class="row buttons">

	<?php echo CHtml::submitButton('Save'); ?>

</div>


<?php 


$this->endWidget(); 


?>


</div><!-- form -->




I was trying to submit the data from textField by click submitButton, but it’s return nothing to my controller. But, when I remove the CJuiDialog, I can get what I typed before from the textfield. Is there something wrong about my CJuiDialog??? Or somebody else know how to solve this???

I’m not really sure but you can try ending the dialog using $this->endWidget(‘zii.widgets.jui.CJuiDialog’);

Thank’s levz, but it didn’t works… :(

Define the complete CActiveForm inside the CJuiDialog widget and you’ll find it will work. You may also use renderPartial() for the active form.

Edit:

On second thought, I’m no longer sure I’ve tested something else than the renderPartial alternative.

(On the other hand, if the dialog fields belongs to a different form, unrelated to the enclosing form, declare the dialog outside of the latter.)

/Tommy

You mean something like this:




beginWidget CActiveForm


  beginWidget CJuiDialog


     beginWidget CActiveForm


        textField    


     endWidget       


  endWidget

   

    submitButton


endWidget



The submitButton won’t respond if there is a form within a form.

To reflect the text you quoted, remove the outer form and move the submit button into the inner form.

(In the other case I did mention, the dialog content represents a different model and will be submitted to a separate controller/action. Also an ID value will be returned to the main form before the dialog is closed.)

/Tommy

I’m so sorry Tri, I didn’t told you completely that outside the widget there are some components such as text Field and radio button that needs to be processed as well.




beginWidget CActiveForm

  textField1

  textField2

  

   some radioButton


  beginWidget CJuiDialog


     beginWidget CActiveForm


        textField    


     endWidget       


  endWidget

   

    submitButton


endWidget



Based on the text I quoted above, jui would encapsulated everything within?? and I can’t get the value to submit it to the same controller/action outside jui? Because I need the data within jui to be submitted simultaneously with the other data from outside jui. That’s why I initiated the form at the very beginning. :(