2

我的自定义组件和模块有问题。我在 XML 表单中创建了这个字段

<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 wiki 似乎不完整,我找不到有关如何解决此问题的有用信息。

谢谢

4

3 回答 3

10

该解决方案是在谷歌群组上找到的。我需要添加filter="safehtml"到该字段

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

我相信这是 Joomla 1.6 特有的,也可能是另一个设置filter="raw"

于 2011-04-28T17:02:11.127 回答
1

您必须添加 JREQUEST_ALLOWRAW 参数才能保留 HTML。

http://docs.joomla.org/How_to_use_the_editor_in_a_component

于 2011-04-26T00:00:19.627 回答
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 );
  }
 } 
于 2011-04-26T04:50:39.580 回答