Custom Modules / Components can't save HTML
I have a problem, with my custom components and modules. In the form XML i created this field
<field name="bio" type="editor" height="250" label="Biography"
description="Intro To The Artist" buttons="true" />
Now the data loads correctly from the DB.
I output the Wyswig e开发者_如何学Cditor and the correct html with this code in the view $this->form->getInput('bio');
However when I save, the form. everything is saved as expected except, all html is stripped.
I don't know where this usually happens, even when I add the XML to a module (the module takes care of all the rendering usually). All displays fine, but the HTML get's stripped.
The Joomla wiki seems incomplete on and I can't find helpful information on how to solve this issue.
Thanks
The solution was found on google groups. I needed to add filter="safehtml"
to the field
<field name="bio" type="editor" height="250" label="Biography" filter="safehtml"
description="Intro To The Artist" buttons="true" />
I believe this is Joomla 1.6 specific, also another setting might be filter="raw"
You have to add the JREQUEST_ALLOWRAW parameter in order to preserve the HTML.
http://docs.joomla.org/How_to_use_the_editor_in_a_component
To get HTML form post data you need to get this data in following way
$data = JRequest::getVar( 'editorName', 'defaultValue', 'post', 'string', JREQUEST_ALLOWRAW );
And need to add a javascript for the view(tmpl file)
function submitbutton(action) {
var form = document.adminForm;
switch(action)
{
case 'save':
case 'apply':
<?php
$editor =& JFactory::getEditor();
echo $editor->save( 'editorName' );
?>
default:
submitform( action );
}
}
精彩评论