2012-03-20 5 views
3

У меня есть компонент, который работал (без настройки HTML-тегов к описанию), и теперь, пытаясь заставить форматирование HTML работать, он не будет сохранен.Компонент Joomla не сохраняет данные

com_lot \ Views \ много \ 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) пропущенное хранилище() для хранения ($ data).

Поскольку страницы перенаправляются и т. Д., Они не умирают и не выходят из строя. Спасибо Ян за вашу помощь.

Смежные вопросы