Joomla Component不保存数据

时间:2012-03-20 20:26:29

标签: joomla

我有一个以前工作的组件(没有为描述设置HTML标记),现在尝试让HTML格式化后,它将无法保存。

com_lot \视图\很多\ TMPL \ form.php的:

<?php defined('_JEXEC') or die('Restricted access');
$document =& JFactory::getDocument();
$document->addScript('includes/js/joomla.javascript.js');
require_once(JPATH_ADMINISTRATOR .DS. 'components' .DS. 'com_jce' .DS. 'helpers' .DS. 'browser.php');
?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<script language="javascript" type="text/javascript">
function submitbutton(pressbutton) {
   var form = document.adminForm;
   if (pressbutton == 'cancel') {
      submitform( pressbutton );
      return;
   }

   <?php
      $editor =& JFactory::getEditor();
      echo $editor->save( 'description' );
   ?>
   submitform(pressbutton);
}
</script>
...
      <tr>
         <td width="100" align="right" class="key">
            <label for="description">
               <?php echo JText::_( 'Description' ); ?>:
            </label>
         </td>
         <td>
            <?php
               $editor =& JFactory::getEditor();
               echo $editor->display('description', $this->lotdata->description, '550', '400', '60', '20', false);
            ?>
         </td>
      </tr>
...
<input type="hidden" name="option" value="com_lot" />
<input type="hidden" name="lotid" value="<?php echo $this->lotdata->lotid; ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="lot" />

<?php echo JHTML::_( 'form.token' ); ?>
<button type="button" onclick="submitbutton('save')"><?php echo JText::_('Save') ?></button>
<button type="button" onclick="submitbutton('cancel')"><?php echo JText::_('Cancel') ?></button>
</form>

com_lot \模型\ lot.php:

   function store($data)
{
   // get the table
   $row =& $this->getTable();

   // Bind the form fields to the hello table
   if (!$row->bind($data)) {
      $this->setError($this->_db->getErrorMsg());
      return false;
   }

   // Make sure the hello record is valid
   if (!$row->check()) {
      $this->setError($this->_db->getErrorMsg());
      return false;
   }

   // Store the web link table to the database
   if (!$row->store()) {
      $this->setError( $row->getErrorMsg() );
      return false;
   }

   return true;         
}

   function save()
   {
   // Check for request forgeries
   JRequest::checkToken() or jexit( 'Invalid Token' );

   // get the model
   $model =& $this->getModel();

   //get data from request
   $post = JRequest::get('post');
   $post['description'] = JRequest::getVar('description', '', 'post', 'string', JREQUEST_ALLOWRAW);

   // let the model save it
   if ($model->store($post)) {
      $message = JText::_('Success');
   } else {
      $message = JText::_('Error while saving');
      $message .= ' ['.$model->getError().'] ';
   }
   $this->setRedirect('index.php?option=com_lot', $message);
}

任何帮助表示感谢。

编辑:我见过有关JForms和XML文件的内容......这适用吗?我没有找到任何说明他们用于什么的地方,只有那些类型......

1 个答案:

答案 0 :(得分:6)

我发现问题(一旦我清理了一下代码)就是我正在关注的文章(http://docs.joomla.org/How_to_use_the_editor_in_a_component)错过了更改商店()来存储($ data) )。

因为页面重定向等,它不会死亡并且错误输出。感谢Jan的帮助。