I'm new to Magento and I'm trying to add an additional button to a pre-existing admin form using an observer. I set up my config to what I believe is the right event handle. I created an observer and added the name and method to config. I don't believe my observer is ever hit since Mage log is not printing. Can anyone see where I'm going wrong?
Sales.xml - (Enterprise layout file)
<layout>
<adminhtml_sales_order_view>
<reference name="content">
<block type="adminhtml/sales_order_view" name="sales_order_edit"></block>
</reference>
</adminhtml_sales_order_view>
</layout>
config.xml
<?xml version="1.0" encoding="UTF-8"?>
<config>
<modules>
<Mycompany_MyModule>
<version>0.1.0</version>
</Mycompany_MyModule>
</modules>
<global>
<events>
<adminhtml_sales_order_view>
<observers>
<my_observer>
<type>singleton</type>
<class>Mycompany_MyModule_Model_Observer</class>
<method>addMyButton</method>
</my_observer>
</observers>
</adminhtml_sales_order_view>
</events>
</global>
</config>
Observer.php
<?php
class Mycompany_MyModule_Model_Observer
{
public function addMyButton($observer)
{
Mage::log('test observer');
$container = $observer->getBlock();
if(null !== $container && $container->getType() == 'adminhtml/sales_order_view')
{
$data = array(
'label' => 'My button',
'class' => 'go',
'onclick' => 'setLocation(\' ' . Mage::getUrl('*/*', array('param' => 'value')) . '\')',
);
$container->addButton('my_button_identifier', $data);
}
return $this;
}
}