Showing posts with label Add WYSIWYG editor to admin custom field. Show all posts
Showing posts with label Add WYSIWYG editor to admin custom field. Show all posts

Monday, 25 July 2011

Add WYSIWYG editor to admin custom field

To enable the editor for a certain editable textfield, just use 'wysiwyg' => true, instead of 'wysiwyg' => false. and add 'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(). i.e.:

$fieldset->addField('description', 'editor', array(
'name' => 'description',
'label' => Mage::helper('sevents')->__('Description'),
'title' => Mage::helper('sevents')->__('Description'),
'style' => 'height:12em;width:500px;',
'wysiwyg' => false,
'required' => true,
));

After Change

$fieldset->addField('description', 'editor', array(
'name' => 'description',
'label' => Mage::helper('sevents')->__('Description'),
'title' => Mage::helper('sevents')->__('Description'),
'style' => 'height:12em;width:500px;',
'wysiwyg' => true,
'required' => true,
'config' => Mage::getSingleton('cms/wysiwyg_config')->getConfig(),
));

also add this to your controller initAction() before return.

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

That's all done.