Page 1 of 1

Tip: Choosing the active tab on a redirect

Posted: Fri Oct 14, 2005 2:43 pm
by calguy1000
Sometimes when you hit the submit button on a tab's form you want to go back to the same tab, or to a different one other than the default.
(applies to the 0.11.2 series or later)

Here's how.
  In your tab setup

Code: Select all

$active_tab = ''';
if( isset( $params['active_tab'] )
   $active_tab = $params['active_tab'];
then

Code: Select all

echo $this->StartTabHeaders();
echo $this->StartTab('tab1','My Tab 1', ($active_tab == 'tab1'))
echo $this->StartTab('tab2','My Tab 2',($active_tab == 'tab2'));
...
Then in your code for handling forms.... when done

Code: Select all

unset( $params['action'] );    // this shouldn't be necessary if using active svn 
$params['active_tab'] = 'tab1';
$this->Redirect($id, 'defaultadmin', '', $params );
Note the empty quotes in the third parameter to Redirect....

Re: Tip: Choosing the active tab on a redirect

Posted: Sun Jun 11, 2006 7:44 am
by prefab
calguy1000 wrote:
then

Code: Select all

echo $this->StartTabHeaders();
echo $this->StartTab('tab1','My Tab 1', ($active_tab == 'tab1'))
echo $this->StartTab('tab2','My Tab 2',($active_tab == 'tab2'));
...
Hello,

Thank you for this tip, I was just looking for a way to do this. I am using 0.13. I looked in the API and it seems that active tab is a parameter for SetTabHeader, rather than StartTab. So the code should be:

Code: Select all

echo $this->StartTabHeaders();
echo $this->SetTabHeader('tab1',$this->Lang('tab1'), ($active_tab == 'tab1'));
echo $this->SetTabHeader('tab2',$this->Lang('tab2'),($active_tab == 'tab2'));
...
There is also more information here
http://wiki.cmsmadesimple.org/index.php ... ertain_tab

cheers