Joomla 如何在创建组件时正确添加任务/操作

Joomla 如何在创建组件时正确添加任务/操作,joomla,joomla2.5,joomla-component,Joomla,Joomla2.5,Joomla Component,我正在为Joomla 2.5的后端做我的第一个组件。 第一部分是确定的,我用通用控制器创建了一个组件,现在我显示了表中的所有元素 为此我遵循了这一点,但现在我想添加像编辑、新建和删除这样的操作。我遵循了这一点,但当我点击编辑,例如。我进入一个白色页面。我的名字组件是Busqueda,我的表是restaurants 这是编辑动作模型/restaurant.php的模型 class BusquedaModelRestaurante extends JModelAdmin{ public f

我正在为Joomla 2.5的后端做我的第一个组件。 第一部分是确定的,我用通用控制器创建了一个组件,现在我显示了表中的所有元素

为此我遵循了这一点,但现在我想添加像编辑、新建和删除这样的操作。我遵循了这一点,但当我点击编辑,例如。我进入一个白色页面。我的名字组件是
Busqueda
,我的表是
restaurants

这是编辑动作模型/restaurant.php的模型

class BusquedaModelRestaurante extends JModelAdmin{

    public function getTable($type= 'Restaurantes', $prefix='RestaurantesTable', $config=array()){
            return JTable::getInstance($type, $prefix, $config);
    }

    public function getForm($data = array(), $loadData = true){
        $form = $this->loadForm('com_busqueda.restaurante', 'restaurante', array('control' => 'jform', 'load_data' => $loadData));
        if (empty($form)) {
            return false;
        }
        return $form;
    }

    protected function loadFormData(){
        $data= JFactory::getApplication()->getUserState('com_busqueda.edit.restaurante.data', array());
        if(empty($data)){
            $data=$this->getItem();
        }
        return $data;
    }
}
这是我的models/forms/form.xml

<?xml version="1.0" encoding="utf-8"?>
<form>
    <fieldset>
        <field
            name="id"
            type="hidden"
        />
        <field name="nombre" type="text" class="inputbox"
            size="40" label="nombre"
            description="Nombre" />

        <field name="direccion" type="text" class="inputbox"
            size="40" label="direccion"
            description="Direccion" />

        ...

    </fieldset>
</form>
在edit.php中

<form action="<?php echo JRoute::_('index.php?option=com_busqueda&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="restaurante-form" class="form-validate">
    <fieldset class="adminform">
        <legend><?php echo JText::_('DETALLES'); ?></legend>
        <ul class="adminformlist">
            <li><?php echo $this->form->getLabel('nombre'); ?>
            <?php echo $this->form->getInput('nombre'); ?></li>

            <li><?php echo $this->form->getLabel('direccion'); ?>
            <?php echo $this->form->getInput('direccion'); ?></li>

....


        </ul>
    </fieldset>
    <div>
        <input type="hidden" name="task" value="" />
        <?php echo JHtml::_('form.token'); ?>
    </div>  

</form>

要查看可能出现的问题,需要在php.ini中启用php错误日志记录。当php xml包过时时,我遇到了这个问题。在php.ini中,您可能需要添加/取消注释这些行

显示PHP错误 php_标志显示上的错误 php_值错误_报告6143

启用PHP错误日志记录 上的php_标志日志_错误 php\u value error\u log/Some\u path/php\u errors.log

您可以尝试以下方法:
<form action="<?php echo JRoute::_('index.php?option=com_busqueda&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="restaurante-form" class="form-validate">
    <fieldset class="adminform">
        <legend><?php echo JText::_('DETALLES'); ?></legend>
        <ul class="adminformlist">
            <li><?php echo $this->form->getLabel('nombre'); ?>
            <?php echo $this->form->getInput('nombre'); ?></li>

            <li><?php echo $this->form->getLabel('direccion'); ?>
            <?php echo $this->form->getInput('direccion'); ?></li>

....


        </ul>
    </fieldset>
    <div>
        <input type="hidden" name="task" value="" />
        <?php echo JHtml::_('form.token'); ?>
    </div>  

</form>