Magento CE 1.8.1.0 – Add Admin Form Field Button

adminformce-1.8.1.0

I am trying to make use of the admin form field with type button.

$fieldset->addField('register', 'button', array(
    'label' => Mage::helper('module')->__('Button Caption'),
    'onclick' => 'test()'
));

however, I expected the label to be actually rendered as the button caption (ON the button) but it is rendered as label text (IN FRONT of the button). I tried, to put title, value, html, innerHTML, looked through the button.php but I cannot figure out how to actually but the button Caption so that Magento renders it like <button>Button Caption</button> there ought to be a way, cause otherwise the button type is pretty much useless.

Best Answer

It should work with value:

$fieldset->addField('register', 'button', array(
    'value' => Mage::helper('module')->__('Button Caption'),
    'onclick' => 'test()'
));

Just make sure that at the end of your form declaration you don't do this:

$form->setValues(....)

This will override the value of the button input. Use this instead.

$form->addValues(....)