2

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.

7

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(....)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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