The module I'm extending adds fields to an admin form using addField()
. I copied this behavior as I thought I would try to stick to their setup. However, I can not figure out how to add the "use default" checkbox to the right of any of these fields. This is an issue as I have a field to add that needs to be site-specific.
Code for posterity sake:
$fieldset->addField('enable_coupon', 'select', array(
'label' => Mage::helper('affiliatepluscoupon')->__('Enable Coupon'),
'name' => 'enable_coupon',
'note' => Mage::helper('affiliatepluscoupon')->__('If yes then it will create a magento salesrule for this store.'),
'values' => Mage::getSingleton('adminhtml/system_config_source_yesno')->toOptionArray(),
));
To clarify, I am looking for the dynamic checkbox that gets put by admin fields that changes based on what view you are on. This shows up automatically when creating fields through the XML but seems to be left out when adding fields with addField()
.
One way you could add a checkbox is
$fieldset->addField('enable_coupon', 'select', array(
....
))->setAfterElementHtml("
<span id='span_use_default'>
<input type='checkbox' value='1' name='use_default' id='use_default' />
Use Default
</span>
");
Also did you check the way they do it in their module?