Magento – Set Active ‘false’ not working in custom tab in magento admin customer edit page

backendcustomermagento-1.9tabs

I have successfully added a custom tab in customer_edit_tabs section and is ordered after orders tab.

However when I go to edit customer page, my custom tab is by default set to active instead showing me default active tab (i.e. Customer View).

I have done this so far but no luck-

protected function _prepareLayout()
    {
        //get all existing tabs
        $this->parent = parent::_prepareLayout();
        //add new tab
        $this->addTab('relate_order', array(
            'label'     => Mage::helper('relate_order')->__('Relate Order'),
            'content'   => $this->getLayout()
             ->createBlock('relate_order/adminhtml_customer_edit_tabs_relate', 'relate.order')->toHtml(),
            'after'     => 'orders',

            //setting non active not working
            'active'    => false
        ));
        return $this->parent;
    }

Even though I have mentioned this new tab to be not active, it still shows up at first.

Please help.

Best Answer

To have the tab active, it either have to be the first or it has to return a boolean true:

\Mage_Adminhtml_Block_Widget_Tabs::addTab
app/code/core/Mage/Adminhtml/Block/Widget/Tabs.php:140
if (is_null($this->_activeTab)) $this->_activeTab = $tabId;
if (true === $this->_tabs[$tabId]->getActive()) $this->setActiveTab($tabId);

You don't return a boolean true, so the first case is yours. You should try to <depends> on Mage_Adminhtml to make sure, your layout xml is loaded later, and your tab is not the first.

Related Topic