Add “wysiwyg” editor in magento Custom Module

Go to the file {your magento root folder}/Block/Adminhtml/{module name}/Edit/Tab/Form.php add following code in top of the file

$fieldset->addField(
'followupemail_text',
'editor', 
array('name'=>'followupemail_text',
'label' => Mage::helper('followupemail')->__('Content'),
'title' => Mage::helper('followupemail')->__('Content'),
'required' => true,
'style' => 'height:24em;','config' => $wysiwygConfig, 
));

go to the file {your magento root folder}/Block/Adminhtml/{module name}/Edit.php add the following line in this file

protected function _prepareLayout()
{
// Load Wysiwyg on demand and Prepare layout
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) {
$block->setCanLoadTinyMce(true);
}
parent::_prepareLayout();
}

Note : Never use “content” as field name.

Leave a Reply

Your email address will not be published. Required fields are marked *