I need to show two tabs in admin custom form in which 2nd tab will only visible after I save the contents of first tab. Any one can tell me the way to do this.

This is what I have -

protected function _beforeToHtml()
    $product_content = $this->getLayout()->createBlock('bulkpricechanger/adminhtml_bulkpricechanger_edit_tab_product', 'adminform_products.grid')->toHtml();
    $serialize_block = $this->getLayout()->createBlock('adminhtml/widget_grid_serializer');
    $serialize_block->initSerializerBlock('adminform_products.grid', 'getSelectedProducts', 'products', 'selected_products');
    $product_content .= $serialize_block->toHtml();
    $this->addTab('associated_products', array(
    'label' => Mage::helper('bulkpricechanger')->__('Select Products'),
    'title' => Mage::helper('bulkpricechanger')->__('Select Products'),
    'content' => $product_content

    // $this->addTab("form_section", array(
    // "label" => Mage::helper("bulkpricechanger")->__("Update Price Settings"),
    // "title" => Mage::helper("bulkpricechanger")->__("pdate Price Settings"),
    // "content" => $this->getLayout()->createBlock("bulkpricechanger/adminhtml_bulkpricechanger_edit_tab_form")->toHtml(),
    // ));

    return parent::_beforeToHtml();

This is what i have in Tab.php I need to show the "form_action" tab to be shown only after products are selected from "associated_produts" tab.

  • Some code you already have might help. – Marius Dec 10 '13 at 12:37
  • I have product grid in first tab of magento custom module admin form. I need to show other form tab when admin selects the product from the grid – Tejas Shah Dec 10 '13 at 12:41
  • You can add an if statement where the second tab is added and where you check if some conditions are met: if (products selected) {$this->addTab(...)}. It's kind of hard to provide code if you don't show what you already have. – Marius Dec 10 '13 at 12:43
  • please check I have updated the question with code. Thanks in advance for you help – Tejas Shah Dec 10 '13 at 13:25
  • Hide the tab with JS? I guess this could only work if the tab doesnt change based on the 1st tabs value... – Si Griffiths May 24 '14 at 8:53

On your tab you can make the function canShowTab. This will return a boolean value if the tab can be shown or not. In this function you can perform a check to see if your conditions are matched. A good example of this is the block Mage_Adminhtml_Block_Customer_Edit_Tab_View which only shows after the customer has been saved.

public function canShowTab()
    if (Mage::registry('current_customer')->getId()) {
        return true;
    return false;
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.