2

In magento admin form Is that possible if status is applied than add button in form.

I mean in custom form there is one field status. Now i want to add button and new tab in form when status is applied.

Is that possible??

If yes than how can i do this?

enter image description here

1
  • @Marius Check it my update hope u can understand now
    – ND17
    Commented Jun 9, 2015 at 8:18

2 Answers 2

3

Yes this is possible,,,,

  1. For tab you can put condition in

app\code\CODE_POOL\NAME_SPACE\MODULENAME\Block\Adminhtml\MODULENAME\Edit\tabs.php

in _beforeToHtml() method you can put your condition like

if($x==3){
 $this->addTab()
}
  1. For button

app\code\CODE_POOL\NAME_SPACE\MODULENAME\Block\Adminhtml\modulename.php

in __construct() method you can put condition like

if($x==3)
{
$this->_addButton(.....)
}

For condition i think you can easily get from Mage::register()(from your controller)

0

you can do this with observers like this.

In your config.xml file add :

<events>
    <adminhtml_block_html_before>
        <observers>
            <add_btn_delete_category_and_rewrite>
                <type>singleton</type>
                     <class>Company_Module_Model_Observer</class>
                <method>addBtn</method>
            </add_btn_delete_category_and_rewrite>
        </observers>
    </adminhtml_block_html_before>
</events>

In your observer,

public function addBtn($observer) {

        $_block = $observer->getBlock();
        $_type = $_block->getType();

        if ($_type == 'adminhtml/catalog_category_edit_form' && CONDITION FOR ATTRIBUTE) { //adapt to the page you want to modify (here the category )


                $_block->addAdditionalButton('btn_name',  array(
                        'name' => 'btn_name',
                        'title'=>'Title',
                        'type'=>"button",
                        'label'=> Mage::helper('catalog')->__('Button'),
                        'onclick'   => YOUR ACTION in controller,
                ));
            }
        }
    }

You should be able to do something similar for the tab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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