7/30/2012

Wysiwyg Editor not working in custom module created by Module creator

When you create a module using module creator then if you try to turn on the Wysiwyg editor of magento then you need to add some function in the Edit.php file which resides under Namespace/Modulename/Block/Adminhtml/Modulename/Edit.php

protected function _prepareLayout() {
    parent::_prepareLayout();
    if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
        $this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
    }
}

Now turn on the Wysiwyg editor in your code which may be like below

$fieldset->addField('summary', 'editor', array(
            'name' => 'summary',
            'label' => Mage::helper('modulename')->__('Description'),
            'title' => Mage::helper('modulename')->__('Description'),
            'style' => 'height:100px;',
            'wysiwyg' => true,
            'required' => true,
        ));

1 comment: