Sunday, 15 March 2015

magento enable WYSIWYG editor in Magento Admin

Hello Friends

Most of the times developers have requirements by their clients to use WYSIWYG editor in magento admin in custom module.  WYSIWYG editor gives end user easy interface to draft their content with nice formatting.

Here we will see that how to enable WYSIWYG editor in Magento admin for our custom module


1)  Loading the TinyMCE library in Head section :

Add the following code in to your module Edit.php block file located  here ( 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);
    }
}


2) Enable WYSIWYG in Form field:

 Add the following code in your Adminhtml Form.php class, located here (Namespace / Modulename / Block / Adminhtml / Edit / Tab / Form.php):

$fieldset->addField('content', 'editor', array(
    'name'      => 'content',
    'label'     => Mage::helper('modulename')->__('Content'),
    'title'     => Mage::helper('modulename')->__('Content'),
    'wysiwyg'   => true,
    'required'  => false,
));


3) Its Done:

check screenshot






Let me know if you have any query

Enjoy.



2 comments:

  1. Useful information shared. I am very happy to read this article. Thanks for giving us nice info. Fantastic walk through. I appreciate this post.
    utah professional web design

    ReplyDelete
  2. Thank you for sharing this information.I have gone through your blog and its very wonderful Magento training in Chennai

    ReplyDelete