Hi all,
I am having difficult redirecting back to the tab that was active before update.
I have these tabs in [color="#FF0000"]MdGenera[/color]l view/form: |General|Training|Education|Experience
On Update mode when you click on Training tab you can view Trainings attended/add new or update existing Trainining attended by Md.If you choose to update you will be taken to [color="#FF0000"]MdTraining contoller[/color] below.
Is there a way I can redirect back to Training tab in [color="#FF0000"]MdGeneral[/color] after update?
public function actionUpdate($id)
{
$model=$this->loadModel($id);
if(isset($_POST['MdTraining']))
{
$model->attributes=$_POST['MdTraining'];
if($model->save())
//move back to Training tab after save
$activeTab='Training'; // id of the tab with your form
else
$activeTab='General'; // id of first tab
$this->redirect(array('MdGeneral/update','id'=>$model->MDID));
}
$this->render('update',array(
'model'=>$model,
));
}
Part of MdGeneral CTabView look like this
<?php $this->beginWidget('system.web.widgets.CClipWidget', array('id'=>'General')); ?>
<table border='1' cellspacing=0 width=100 height=150>
</table>
<?php $this->endWidget(); ?>
<?php $this->beginWidget('system.web.widgets.CClipWidget', array('id'=>'Training')); ?>
<table border='1' cellspacing=0 width=100 height=150>
</table>
<?php $this->endWidget(); ?>
<?php
$tabParameters = array();
foreach($this->clips as $key=>$clip)
$tabParameters['tab'.(count($tabParameters)+1)] = array('title'=>$key, 'content'=>$clip);
?>
<?php $this->widget('system.web.widgets.CTabView', array('tabs'=>$tabParameters)); ?>
<div class="row_buttons">
<?php echo CHtml::submitButton('Save',array('name'=>($model->isNewRecord)?'create':'update')); ?>
</div>
<?php $this->endWidget(); ?>
Any help will be much appreciated. Thanks in advance.