2012-03-20 63 views
3

我有一個組件工作(沒有設置HTML標籤的描述),現在試圖讓HTML格式工作後,它不會保存。Joomla組件不保存數據

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文件的東西......這是否適用?我沒有發現任何地方說什麼他們用於什麼類型有...

回答

6

我發現問題(一旦我清理了一下代碼)是在文章中我正在關注(http://docs.joomla.org/How_to_use_the_editor_in_a_component)錯過了更改store()以存儲($ data)。

由於頁面重定向等,它不會死亡和出錯。感謝Jan的幫助。