I want to put a button after fieldset legend as shown in fig.

I have tried the code below to achieve this but that not works.

how can I do this..?

enter image description here

$fieldset = $form->addFieldset('custom_fieldset', array(
                                   'legend'=>Mage::helper('cms')->__('Custom Block'),
                                   'after_element_html' => '<button type="button" onclick="alert(\'click me!!\')">click</button>',

1 Answer 1


This one should work for you:

$fieldset->setHeaderBar('<button type="button" onclick="alert(\'click me!!\')">click</button>');

Just call it after you create your fieldset.

You may also use api to create button code itself:

$button = $this->getLayout()->createBlock('adminhtml/widget_button')
        'label'   => 'My Button',
        'onclick' => 'return false;',
        'class'   => 'some-class',


This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .