2

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

2

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')
    ->setData(array(
        'label'   => 'My Button',
        'onclick' => 'return false;',
        'class'   => 'some-class',
    ));
$button->setName('some_button');

$fieldset->setHeaderBar($button->toHtml());
0

Your Answer

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

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