Thursday, August 1, 2013

How to use WYSIWYG editor in Admin form field Magento


>> You need to do two small changes. Here's it

    1) open the Edit.php page on your module Yourmodule_Block_Adminhtml_Yourblock_Edit
    Add the method.

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


    2) Now open the Form.php change the field you want to change like following:

        $fieldset->addField('description', 'editor', array(
            'name'      => 'description',
            'label'     => Mage::helper('Youmodule')->__('Content'),
            'title'     => Mage::helper('Youmodule')->__('Content'),
            'style'     => 'height:300px; width:700px',
            'config'    => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
            'wysiwyg'   => true,

            'required'  => false,
        ));

     ...........................

No comments:

Post a Comment