This extension works in similar fashion to CTabView, but is intended to be used inside a form. This extension adds a single hidden field in wich value's is stored the actual selected tab. So, in our controller we can ask for that field to know the actual selected tab.
protected/extensionsThe usage is the same of the CTabView, except that we must specify the name of the hidden field (or model/attribute):
In our view:
<div class="yiiForm"> <?php echo CHtml::form(); <?php echo CHtml::errorSummary($someModel); <div class="simple"> <?php echo CHtml::activeLabelEx($someModel,'attr1'); <?php echo CHtml::activeTextField($someModel,'attr1'); </div> <div class="simple"> <?php echo CHtml::activeLabelEx($someModel,'attr2'); <?php echo CHtml::activeTextField($someModel,'attr2'); </div> <?php $Tabs = array(...); $viewData = array(...); $this->widget( 'application.extensions.ActiveTabView.EActiveTabView', array( 'tabs'=>$Tabs, 'viewData'=>$viewData, 'model'=>$someModel, 'attribute'=>'attr3' )); // OR $this->widget( 'application.extensions.ActiveTabView.EActiveTabView', array( 'tabs'=>$Tabs, 'viewData'=>$viewData, 'name'=>'someName' )); <div class="action"> <?php echo CHtml::submitButton(); </div> <?php echo CHtml::closeTag('form'); </div><!-- yiiForm -->
So in our controller we can do the following:
public function actionUpdate() { $someModel=new SomeModel; if(isset($_POST['SomeModel'])) { // In the case that we specify model/attribute. $someModel->attributes=$_POST['SomeModel']; // $someModel->attr3 has the ID of the actual selected tab // OR, in the case that we specify the name. $selectedTab = $_POST['someName']; // $selectedTab has the ID of the actual selected tab // do ther stuff } // render view, etc,etc }
Total 2 comments
I haste. Selected tab is ok, but not work changing tabs. ???
That is exactly what I'm looking for
Leave a comment
Please login to leave your comment.