Hi guys.
In order to submit all CJuiTabs together, they must be part of the same form.
You thus need to first create a mainform containing the CJuiTabs.
<div class="form"> <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'default-parent-form', 'enableAjaxValidation'=>false, )); <?php $tabs = array(); $tabs['Tab1 Name'] = array( 'id'=>'dataFieldsTab', 'content'=>$this->renderPartial('_formDataFields', array( 'form' => $form, 'parent_model'=>$parent_model, ), true), ); $tabs['Tab2 Name'] = array( 'id'=>'linkedChildrenTab1', 'content'=>$this->renderPartial('_formChildren1', array( 'form' => $form, 'child_model'=>$child_model, ), true), ); $this->widget('zii.widgets.jui.CJuiTabs', array( 'tabs' => $tabs, 'options' => array( 'collapsible' => false, ), )); <?php $this->endWidget(); </div><!-- form -->
Each tab has a separate individual view. Mine are called _formDataFields and _formChildren1.
Here is an example of _formDataFields:
echo $form->errorSummary($parent_model); <div class="row"> <?php echo $form->labelEx($parent_model,'branch_nr'); <?php echo $form->textField($parent_model,'branch_nr'); <?php echo $form->error($parent_model,'branch_nr'); </div> <div class="row"> <?php echo $form->labelEx($parent_model,'branch_name'); <?php echo $form->textField($parent_model,'branch_name'); <?php echo $form->error($parent_model,'branch_name'); </div>
You will see that $form is created in the mainform, and then passed by the CJuiTabs to each individual view, where it is used in the fields. So eventually the mainform and all the views on the tabs, form part of the same $form. This ensures that all tabs are submitted simultaniously.
The controller needs to pass ALL needed models to the mainform, where each tab passes $form and the individual model further to the views. (Obviously you can pass multiple models to the individual views if needed.)
After submission, you have to test in the controller that you received all models back from the client e.g.
if(isset($_POST['ar_parent_model'])) { ... } if(isset($_POST['ar_child_model'])) { ... }
Tip: You can display a CGridView on its own CJuiTab. Just pass it the model which it needs to store the user's filtering criteria - if any.
Hope this helps someone.