PHP-Joomla:在自定义视图中保存表单时出错
作者:互联网
我创建了一个具有表单的自定义组件,用于更新要在前端显示的四种产品的价格.
我的主控制器代码在这里:
public function display($cachable = false, $urlparams = false) {
require_once JPATH_COMPONENT.'/helpers/calculator.php';
$view = JFactory::getApplication()->input->getCmd('view', 'pricetable');
$layout = JFactory::getApplication()->input->getCmd('layout', 'edit');
JFactory::getApplication()->input->set( 'layout', $layout );
JFactory::getApplication()->input->set('view', $view);
JFactory::getApplication()->input->set('id', 1);
parent::display($cachable, $urlparams);
return $this;
}
id设置为1,因此它仅从数据库加载第一行.
价格表容器的代码是:
function __construct() {
$this->view_list = 'pricetable';
parent::__construct();
}
现在,在后台管理中,表格将根据需要与第一行数据一起加载.
当我尝试保存表单时,将其重定向到administrator / index.php?option = com_calculator& view = pricetable,错误为:
Error: You are not permitted to use that link to directly access that
page (#1).
我的表单动作是:
<?php echo JRoute::_('index.php?option=com_calculator&task=pricetable.edit&id='.(int) $this->item->id); ?>
请指出我做错了什么.这是第三天,我挠头.
标签:joomla3-0,model-view-controller,joomla,joomla-component,php 来源: https://codeday.me/bug/20191031/1972688.html