2011-04-25 32 views
2

我有一个问题,与我的自定义组件和模块。在XML中,我创建了这个字段自定义模块/组件不能保存HTML

<field name="bio" type="editor" height="250" label="Biography" 
      description="Intro To The Artist" buttons="true" /> 

现在数据从数据库中正确加载。 我输出Wyswig编辑器和正确的HTML代码在视图$this->form->getInput('bio'); 然而,当我保存,形式。除了所有的HTML都被删除之外,所有内容都按预期保存。

即使将XML添加到模块(模块通常会处理所有的渲染),我也不知道通常会发生什么情况。所有显示都很好,但HTML获取已被删除。

该Joomla维基似乎不完整,我找不到有用的信息如何解决这个问题。

感谢

回答

10

该解决方案在谷歌组上找到。我需要添加filter="safehtml"到外地

<field name="bio" type="editor" height="250" label="Biography" filter="safehtml" 
      description="Intro To The Artist" buttons="true" /> 

我相信这是1.6的Joomla特定的,还另设置可能是filter="raw"

+0

+1谢谢,我正在寻找这一切。 – VirtuosiMedia 2011-12-15 19:11:40

+0

你是对的,有一个像JavaScript过滤器'原料'..本文包括所有筛选器选项: http://joomla-answers.blogspot.com/2012/07/html-is-stripped-in -joomla-component.html – 2012-07-26 10:56:27

+0

+1你帮了忙。谢谢! – 2013-02-16 14:53:25

1

您必须添加JREQUEST_ALLOWRAW参数,以保存HTML。

http://docs.joomla.org/How_to_use_the_editor_in_a_component

+0

谢谢,我会考虑这在接下来的24小时,看看它是否工作 – Moak 2011-04-26 05:15:06

+0

对不起,这对我工作的Joomla 1.6模块和组件无效,谢谢 – Moak 2011-04-28 17:03:03

+0

哎呦。我没有注意到1.6标签。这是专门为1.5。 – 2011-04-28 20:07:10

1

要获得HTML表单提交数据,需要在以下方式

$data = JRequest::getVar('editorName', 'defaultValue', 'post', 'string', JREQUEST_ALLOWRAW); 

得到这个数据,需要添加Javascript的视图(TMPL文件)

function submitbutton(action) { 
    var form = document.adminForm; 
    switch(action) 
    { 
    case 'save': 
    case 'apply': 
    <?php 
       $editor =& JFactory::getEditor(); 
       echo $editor->save('editorName'); 
     ?> 
    default: 
    submitform(action); 
    } 
} 
+0

对不起,这并没有工作在我工作的Joomla 1.6模块和组件,谢谢 – Moak 2011-04-28 17:03:08