Magento – Integrate WYSIWYG TinyMCE in Admin Custom Module and Contact Us / CMS Page

cmscontact-ustinymcewysiwyg

I followed this blog to add WYSIWYG editor (TinyMCE) in my custom Admin Magento Module. I can see it in my backend, but the issue is when I click on Insert Image, Insert Variable or Insert Widget, it shows me JS error in my Error Console.

Could someone shed some light on how to integrate WYSIWYG in backend as well as on frontend (ex: Contact Us Page) with the correct Magento approach.

Thanks

Best Answer

It looks like your page is missing the inclusion of the widget.js file. This is normally added in the admin section based on the layout handle editor.

<action method="addJs"><script>mage/adminhtml/wysiwyg/widget.js</script></action>

I would suggest that for you custom page you also add the editor layout handle to include add the js and css required.

<your_customer_handle>
    <update handle="editor"/>
</your_customer_handle>