Magento – Custom button in Admin Form

adminhtmlformsmagento-1.7

I need to add a button in my custom module admin form , which calls an action 'upload'

How can I achieve it ?

Best Answer

When defining a form element you have the option of specifying after_element_html. what you put there will be shown after the element itself. Here is an example:

$fieldset->addField('some_field', 'text', array(
    'label' => Mage::helper('core')->__('Some label'),
    'name'  => 'some_name',
    'after_element_html' => '<button type="button" onclick="alert(\'Stop clicking me!!\')">Do not click</button>' 
));

I think you can start from here. you can use the onclick on the button to do an ajax call (or something like that) and upload your image.