In previous post we learnt how to render custom html in tabs block. Now lets add custom JavaScript in Magento admin form. Magento is flexible enough to insert your custom JavaScript code snippets in forms created by your very own Magento modules & extensions. You can put Add custom Javascript in Magento admin form
Last modified
setAfterElementHtml
method right after addField
as shown below.
$field = $fieldset->addField('title', 'text', array(
'label' => Mage::helper('module')->__('Title'),
'name' => 'title',
'required' => true,
'class' => 'required-entry input-text',
));
$field->setAfterElementHtml('<script>
//< ![C
// here goes your custom Javascript
//]]>
</script>');
5 min read