Posted on

Magento adminpanel custom Module editor field config

I have created a custom module in the adminpanel where i need to show an HTML editor. The field is showing properly with the HTML editor but the issue is that its showing all the buttons and options in the editor (Please see the image below).

But i only want to show options like Bold,Italic,Underscore. How can i do this. Here is the code im using to show the editor.

app/code/local/MyModule/Producteditrequest/Block/Adminhtml/Producteditrequest/Edit/Tab/Form.php

protected function _prepareForm(){

$form = new Varien_Data_Form(array(‘id’ => ‘edit_form’,
‘action’ => $this->getUrl(‘*/*/save’, array(‘id’ => $this->getRequest()->getParam(‘id’))),
‘method’ => ‘post’,
));
$fieldset = $form->addFieldset(‘producteditrequest_form’, array(‘legend’=>Mage::helper(‘producteditrequest’)->__(‘Edit Request ‘)));
.
.
.
.
.
.
.
$fieldset->addField(‘shortdesc’, ‘editor’, array(
‘name’ => ‘shortdesc’,
‘label’ => Mage::helper(‘producteditrequest’)->__(‘Short Description’),
‘title’ => Mage::helper(‘producteditrequest’)->__(‘Short Description’),
‘style’ => ‘width:98%; height:200px;’,
‘wysiwyg’ => true,
‘config’ => Mage::getSingleton(‘cms/wysiwyg_config’)->getConfig(),
‘required’ => true,
‘value’ => $pdtEditDetails[‘short_desc’]
));
$this->setForm($form);
.
.
.
}

[Please note that i have only included the relevant parts of my code since its a very big function]

I have tried following methods to configure the editor which found from
/app/code/core/Mage/Adminhtml/Block/Catalog/Helper/Form/Wysiwyg/Content.php

$config = array()
$config[‘add_variables’] = false;
$config[‘add_widgets’] = false;
$config[‘add_directives’] = true;
$config[‘use_container’] = true;
$config[‘container_class’] = ‘hor-scroll’;

$fieldset->addField(‘shortdesc’, ‘editor’, array(
‘name’ => ‘shortdesc’,
‘label’ => Mage::helper(‘producteditrequest’)->__(‘Short Description’),
‘title’ => Mage::helper(‘producteditrequest’)->__(‘Short Description’),
‘style’ => ‘width:98%; height:200px;’,
‘wysiwyg’ => true,
‘config’ => Mage::getSingleton(‘cms/wysiwyg_config’)->getConfig($config),
‘required’ => true,
‘value’ => $pdtEditDetails[‘short_desc’]
));

But still its showing all the options as in the above image.

I have also tried putting following javascript code in the phtml file.

<script type=”text/javascript”>
window.onload=function()
{
tinyMCE.init({
mode : “exact”,
elements: “shortdesc”,
theme : “advanced”,
theme_advanced_buttons1 : “bold,italic,underline,strikethrough,|”,
doctype : ‘<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>’

});
};
</script>

But there is no change.

How can i make the editor configurable in the adminpanel.

Leave a Reply

Your email address will not be published.