I’ve a working backend module with various forms to manage several different tables. On one of the forms I have a radio button group (radios element on Magento). Here is the code snippet for this radio group:
//radio group
$fieldset->addField('radio_group', 'radios', array(
'label' => Mage::helper('banners')->__('Select campaign type'),
'name' => 'title',
'onclick' => '',
'onchange' => '',
'value' => '1',
'values' => array(
array('value'=>'1','label'=>'Imagen'),
array('value'=>'2','label'=>'HTML'),
array('value'=>'3','label'=>'Producto'),
),
'disabled' => false,
'readonly' => false,
'tabindex' => 3
));
There is no way I can find how to manage the onclik and the onchange events. Where do I need to add the code? The actions to be executed are simple, I’ll just enable/disable other controls on the same page according to the selected radio button.
Any suggestion, sample code, tutorial? I’ve done lot of googling with no luck, I’ve found lot of samples but all refered to how to setup a new admin form, wich I have already done not once but several times.
One way you could get around this issue is by adding update layout.xml to your module (or a local.xml)
You can include your js in layout.xml using two different method, the only different is where you need to put your js file
Javascript location : /js/your_js_file.js
or
Javascript location : /skin/adminhtml/default/default/your_js_file.js
Add a css class name to each radio button
In your_js_file.js ( http://fiddle.jshell.net/hX2u3/ )