Yii 1.1: activetabview

EActiveTabView allow us to keep track of the actual selected tab inside a form...
2 followers

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.

Resources

Documentation

Requirements

  • Yii 1.0.3 or above

Installation

  • Extract the release file under protected/extensions

Usage

The 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
}

Change Log

March 27, 2009

  • Initial release.

Total 2 comments

#209 report it
Deimos at 2010/08/08 07:26am
not work

I haste. Selected tab is ok, but not work changing tabs. ???

#210 report it
Deimos at 2010/08/08 07:06am
Thanks

That is exactly what I'm looking for

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: PoL
  • Category: User Interface
  • Votes: -2
  • Downloaded: 540 times
  • Created on: Mar 27, 2009
  • Last updated: Mar 27, 2009