Hi guys, in my application i'm going to use a form in CJuiTabs, where i want to have the id for each tab posted to the new record as well. How can i do this?
My current code for it is:
View:
Platform model:
_form:
My current code for it is:
View:
<?php $tab_list=Platform::getPlatforms(); $tabarray=array(); // Create Dynamic Tabs foreach($tab_list as $key=>$value){ $tabarray["$value"]=array( 'id'=>$key, 'content'=>$this->renderPartial('../ranking/_form', array('model'=>$ranking),TRUE) ); }?> <?php $this->widget('zii.widgets.jui.CJuiTabs',array( 'tabs'=>$tabarray, 'options'=>array( 'collapsible'=>true, ), 'id'=>'categorytabs', )); ?>
Platform model:
class Platform extends CActiveRecord { const PC = 1; const Mac = 2; const XBOX = 3; const XBOX360 = 4; const PS2 = 5; const PS3 = 6; const PSP = 7; const PSVITA = 8; const Wii = 9; const WiiU = 10; const NintendoDS = 11; const NintendoDS3 = 12; ... public function getPlatforms() { $id = Yii::app()->request->getQuery('id'); $platform = Platform::model()->findByPk($id); $platforms = array(); if ($platform -> pc == 1) { $platforms[self::PC] = "PC"; } if ($platform -> xbox == 1) { $platforms[self::XBOX] = 'XBOX'; } if ($platform -> xbox360 == 1) { $platforms[self::XBOX360] = "XBOX 360"; } if ($platform -> ps2 == 1) { $platforms[self::PS2] = "PS2"; } if ($platform -> ps3 == 1) { $platforms[self::PS3] = 'PS3'; } if ($platform -> psp == 1) { $platforms[self::PSP] = "PSP"; } if ($platform -> psVita == 1) { $platforms[self::PSVITA] = 'PS VITA'; } if ($platform -> wii == 1) { $platforms[self::Wii] = "Wii"; } if ($platform -> wiiU == 1) { $platforms[self::WiiU] = "Wii U"; } if ($platform -> nintendoDS == 1) { $platforms[self::NintendoDS] = 'Nintendo DS'; } if ($platform -> nintendoDS3 == 1) { $platforms[self::NintendoDS3] = 'Nintendo DS3'; } return $platforms; } }
_form:
<?php ?> <div class="form"> <?php $form=$this->beginWidget('CActiveForm', array( 'id'=>'ranking-form', 'enableAjaxValidation'=>false, )); ?> <p class="note">Fields with <span class="required">*</span> are required.</p> <?php echo $form->errorSummary($model); ?> <div class="row"> <?php echo $form->labelEx($model,'overall'); ?> <?php $this->widget('CStarRating',array( 'model'=>$model, 'attribute' => 'overall', )); ?> <?php echo $form->error($model,'overall'); ?> </div> <br/> <div class="row"> <?php echo $form->labelEx($model,'graphics'); ?> <?php $this->widget('CStarRating',array( 'model'=>$model, 'attribute' => 'graphics', )); ?> <?php echo $form->error($model,'graphics'); ?> </div> <br/> <div class="row"> <?php echo $form->labelEx($model,'sound'); ?> <?php $this->widget('CStarRating',array( 'model'=>$model, 'attribute' => 'sound', )); ?> <?php echo $form->error($model,'sound'); ?> </div> <br/> <div class="row"> <?php echo $form->labelEx($model,'gameplay'); ?> <?php $this->widget('CStarRating',array( 'model'=>$model, 'attribute' => 'gameplay', )); ?> <?php echo $form->error($model,'gameplay'); ?> </div> <br/> <div class="row"> <?php echo $form->labelEx($model,'lastingApp'); ?> <?php $this->widget('CStarRating',array( 'model'=>$model, 'attribute' => 'lastingApp', )); ?> <?php echo $form->error($model,'gameplay'); ?> </div> <br/> <div class="row buttons"> <?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?> </div> <?php $this->endWidget(); ?> </div>