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',


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.