Add tinyMCE editor in magento custom module

If we have created a custom module using Magento Module creator means, it will not contain ‘wysiwyg(tinyMCE)’ editor feature.
We can add the ‘wysiwyg’ editor in custom module within 2 steps.
Step 1:
Add the following code in /controllers/Adminhtml/BlogController.php under the line $this->getLayout()->getBlock('head')->setCanLoadExtJs(true).

if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {

Step 2:Add the following code in /Block/Adminhtml/Blog/Edit/Tab/Form.php file, within your field declaration.

'config'      => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),

Now, it will look like this

$fieldset->addField('post_content', 'editor', array(
'name' => 'post_content',
'label' => Mage::helper('blog')->__('Content'),
'title' => Mage::helper('blog')->__('Content'),
'style' => 'width:900px; height:500px;',
'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
'wysiwyg' => true,
'required' => true,

That’s it! We have added tinyMCE editor in our magento custom module:)

Note: Field name should not be ‘content’ if you keep your field as ‘content'(which is already available), editor will be shown all over the admin content block. So give some other name for content filed.


 Add your comment
  1. Hi Pankaj, please follow the above sangam's replay link. It's helped me to get the widget with full functionality as like in CMS module.

  2. Same issue with me. I am only geting show/hide editor button, i cleared the cache, and followed the steps but no luck, early help is appriciated

  3. Dhara try it once again after clearing cache. Please make sure that you have followed those 2 steps correctly! It's worked perfectly for me. The only problem in this code is i couldn't not able to insert image using image widget. This post having step-by-step screenshot feel free to follow that 🙂

  4. show/hide editor button is display, but editor not display.

  5. No problem you have fixed your self 😉 Thanks for commenting:)

  6. I fixed it, it was the issue with the field name being called 'content' Sorry to waste your time 🙂

  7. Hi, thanks for the tutorial, one problem I've encountered is that after following this guide the whole form is placed within the wysiwyg editor rather than just applying the editor to the specified field.

    Any advice?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: