I'm creating a custom magento widget with the WYSIWYG editor as a widget option.
I followed those two pages as initial setup http://www.behrendt.io/2013/04/12/using-a-wysiwyg-editor-in-a-magento-widget/ https://stackoverflow.com/questions/15767894/magento-add-wysiwyg-editor-to-custom-widget/15953843#15953843
Currently I see the editor appearing, but by saving the widget I run into some errors.
First of all there is the text attribute missing in the widget declaration
{{widget type="widgetone/slideshow"}}
When i try to save the widget i get the following javascript alert
I already looked in the web but didn't found anything helpful.
I'm using magento CE 1.7.0.2 and here you can see my widget code:
widget.xml
<company_widgetone_slideshow type="widgetone/slideshow" translate="name description">
<name>Slideshow</name>
<description type="desc">Description</description>
<parameters>
<text translate="label">
<label>Text</label>
<visible>1</visible>
<type>widgetone/widget_wysiwyg</type>
</text>
</parameters>
</company_widgetone_slideshow>
My widget block
class Company_WidgetOne_Block_Widget_Wysiwyg extends Mage_Adminhtml_Block_Widget_Form_Renderer_Fieldset_Element {
public function render(Varien_Data_Form_Element_Abstract $element)
{
Mage::log("block");
$editor = new Varien_Data_Form_Element_Editor($element->getData());
// Prevent foreach error
$editor->getConfig()->setPlugins(array());
$editor->setId($element->getId());
$editor->setForm($element->getForm());
$editor->setWysiwyg(true);
$editor->setForceLoad(true);
return parent::render($editor);
} }
If i try to override the magento Widget Model (as showen in the second link above)
class Company_WidgetOne_Model_Widget extends Mage_Widget_Model_Widget {
public function getWidgetDeclaration($type, $params = array(), $asIs = true)
{
Mage::log($params);
if( preg_match('~(^widgetone/slideshow)~', $type) )
{
$params['text'] = str_replace('"', "'", $params['text']);
}
return parent::getWidgetDeclaration($type, $params, $asIs);
}
}
The $params
array is always empty ..
Also the post-parameter parameters[text]
in the ajax call when saving the widget is empty
Please provide any possible idea you have to solve this issue
Thanks !!