I added category attribute (textarea) and Magento stops displaying WYSIWYG button if I use custom renderer for that textarea field. I want to ask I anyone knows why this happens?
Here are my steps. I added category attribute, a simple textarea with WYSIWYG button:
$installer->addAttribute('catalog_category', 'my_attr1', array(
'label' => 'My attribute 1',
'type' => 'text',
'input' => 'textarea',
'visible_on_front' => true,
'wysiwyg_enabled' => true,
'is_html_allowed_on_front' => true,
'visible' => true,
'required' => false,
'backend' => '',
'frontend' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
All works correct, WYSIWYG button is displayed below the field.
Then I added second attribute my_attr2
to make some tests. That second attribute use my custom renderer class (see 'input_renderer' => 'my_custom'
) because I need to extend that field with additional functionality. I checked that attribute was added correct and works 100% correct. That class My_Custom
extends Magento's default textarea renderer Varien_Data_Form_Element_Textarea
so it looks and works exactly the same as standard textarea field.
But for some reason Magento stops displaying WYSIWYG button if I use custom renderer.
$installer->addAttribute('catalog_category', 'my_attr2', array(
'label' => 'My attribute 2',
'type' => 'text',
'input' => 'textarea',
'input_renderer' => 'my_custom', //<---custom
'visible_on_front' => true,
'wysiwyg_enabled' => true,
'is_html_allowed_on_front' => true,
'visible' => true,
'required' => false,
'backend' => '',
'frontend' => '',
'searchable' => false,
'filterable' => false,
'comparable' => false,
'global' => Mage_Catalog_Model_Resource_Eav_Attribute::SCOPE_STORE,
));
Here's the rendered class (located in file lib/My/Custom.php). I checked that Magento for sure use this class when rendering the second attribute (I added logging to the constructor to make sure it works).
<?php
class My_Custom extends Varien_Data_Form_Element_Textarea
{
public function __construct($attributes=array())
{
parent::__construct($attributes);
Mage::log("My_Custom is working");
}
}
Even If I remove all the code from the renderer class lib/My/Custom.php to make sure I didn't break or override anything, the WYSIWYG button is still not displayed below the second attribute:
<?php
class My_Custom extends Varien_Data_Form_Element_Textarea
{
}
And as soon as I update my_attr2
and remove the custom renderer class, then the WYSIWYG button is displayed correct below the textarea (just like it should be).
Mage_Adminhtml_Block_Catalog_Helper_Form_Wysiwyg