сохранить поле формы в компонентах params joomla

Я использую Joomla 2.5, я работаю над пользовательским компонентом Joomla. Я создал форму на административной странице бэкэнда. что мне нужно, я хочу сохранить данные поста формы вparams строка этого компонента в базе данных#_extensions, Вот мои таблицы / component.php

<?php defined('_JEXEC') or die('Restricted access');

jimport ( 'joomla.database.table');

класс componentTablecomponent extends JTable {

function __construct(&$db)
{
    parent::__construct('#__extensions', 'extension_id', $db);
}

public function bind($array, $ignore = '')
{
    if (isset($array['params']) && is_array($array['params']))
    {
        // Convert the params field to a string.
        $parameter = new JRegistry;
        $parameter->loadArray($array['params']);
        $array['params'] = (string)$parameter;
    }
    return parent::bind($array, $ignore);
}


public function load($pk = null, $reset = true)
{
    if (parent::load($pk, $reset))
    {
        // Convert the params field to a registry.
        $params = new JRegistry;
        $params->loadJSON($this->params);
        $this->params = $params;
        return true;
    }
    else
    {
        return false;
    }
} public function store() {

Родитель :: магазин (нуль);

}

}

Вместо сохранения$data вparams строка этого компонента. Этот код создает новые пустые строки в этой таблице (данные сохраняются в техparams поле). Вот мойsave() функция в controllers / component.php

публичная функция save ()

{
    // Check for request forgeries.
    JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

    // Check if the user is authorized to do this.
    if (!JFactory::getUser()->authorise('core.admin'))
    {
        `JFactory::getApplication()->redirect('index.php',JText::_('JERROR_ALERTNOAUTHOR'));`
        return;
    }



    // Initialise variables.
    $app  = JFactory::getApplication();
    $model    = $this->getModel('component');
    $form = $model->getForm();
    $data = JRequest::getVar('jform', array(), 'post', 'array');
    print_r($data);
    // Validate the posted data.
    $return = $model->validate($form, $data);

    // Check for validation errors.
    if ($return === false)
    {
        // Get the validation messages.
        $errors   = $model->getErrors();

        // Push up to three validation messages out to the user.
        for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
            if ($errors[$i] instanceof Exception) {
                $app->enqueueMessage($errors[$i]->getMessage(), 'warning');
            } else {
                $app->enqueueMessage($errors[$i], 'warning');
            }
        }

        // Redirect back to the edit screen.
$this->setRedirect(JRoute::_('somelink',false));

        return false;
    }

    // Attempt to save the configuration.
    $data = $return;
    $return = $model->save($data);

    // Check the return value.
    if ($return === false)
    {


        // Save failed, go back to the screen and display a notice.
        $message = JText::sprintf('JERROR_SAVE_FAILED', $model->getError());
$this->setRedirect('index.php/somelink','error');      

        return false;
    }

    // Set the success message.
    $message = JText::_('COM_CONFIG_SAVE_SUCCESS');

    // Set the redirect based on the task.
    switch ($this->getTask())
    {
        case 'apply':
            $this->setRedirect('somelink',$message);

            break;
        case 'cancel':
        case 'save':

        default:
            $this->setRedirect('index.php', $message);
            break;
    }

    return true;
}

модели / component.php

публичная функция save ($ data) {

    parent::save($data);
    return true; 
}

Я думаю, что этих кодов достаточно. Я могу добавить больше кодов, если вам нужно.

Ответы на вопрос(2)

Ваш ответ на вопрос