wysiwyg editor in Magento Custom Module

Magento WYSIWYG Editor

wysiwyg editor in Magento Custom Module : This is very and well known problem for every magento developer . so here is a simple solutions to add the wysiwyg editor in magento module  development .

Step 1 – Go to app/code/local/Webkul/Faq/Block here webkul is namespace and faq is module name , under your _prepareLayout() function add this code

[stextbox id=”info” shadow=”true”]public function _prepareLayout()
if (Mage::getSingleton(‘cms/wysiwyg_config’)->isEnabled() && ($block = $this->getLayout()->getBlock(‘head’))) {
return parent::_prepareLayout();

Then go to app/code/local/Webkul/Faq/Block/Adminhtml/Faq/Edit/Tab

and add following code in your _prepareForm() function  below your setform() . $this->setForm($form);

[stextbox id=”info” shadow=”true”]$wysiwygConfig = Mage::getSingleton(‘cms/wysiwyg_config’)->getConfig(array(‘add_variables’ => false, ‘add_widgets’ => false,’files_browser_window_url’=>$this->getBaseUrl().’admin/cms_wysiwyg_images/index/’));[/stextbox]

then define this as $fieldset

[stextbox id=”info” shadow=”true”]$fieldset->addField(‘body’, ‘editor’, array(
          ‘name’      => ‘body’,
          ‘label’     => Mage::helper(‘faq’)->__(‘Content’),
          ‘title’     => Mage::helper(‘faq’)->__(‘Content’),
          ‘style’     => ‘width:700px; height:500px;’,
          ‘state’     => ‘html’,
          ‘config’      => $wysiwygConfig,
          ‘wysiwyg’   => true,
          ‘required’  => true,

now go to app/design/adminhtml/default/default/layout and add this xml code
[stextbox id=”info” shadow=”true”]<faq_adminhtml_faq_edit>
       <update handle=”editor”/>

where first faq is module name and second faq is model name . Bingo you have working wysiwyg editor in magento 🙂

Reindex data from magento after adding this