在issubmit之后定义页面

时间:2017-02-17 18:12:03

标签: prestashop prestashop-1.6

我在Prestashop中写了我的第一个模块。当我在后台提交数据时,它会加载我的模块的配置页面。但我想留在表格中。我怎样才能做到这一点?

if (Tools::isSubmit('toggleanswers')) {
        $id_answer = Tools::getValue('id_answer');
        if($this->toggleAnswer($id_answer)) {
            $this->_html .= $this->displayConfirmation($this->l('Entry status changed'));
        }

        else {
            $this->_html .= $this->displayError(implode($this->_errors, '<br />'));
        }
}

这是我的功能的样子。单击切换后,它不应该返回到配置页面...我的表单的URL如下所示:/index.php ?controller = AdminModules&amp; configuration = itemstions&amp; module_name = items&amp; id_question = 1&amp; updatedtionsquestions&amp ;token = ccd237618500f4c18f42d1a4fe971aa9

1 个答案:

答案 0 :(得分:0)

如果我理解你想要什么,你应该改变你的代码:

if (Tools::isSubmit('toggleanswers')) {
    $id_answer = Tools::getValue('id_answer');
    if($this->toggleAnswer($id_answer)) {
        Tools::redirectAdmin($this->context->link->getAdminLink('AdminModules', true).'&conf=6&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name.'&id_question='.$id_question.'&update_questions');
    } 
    else
    {
        $this->_html .= $this->displayError(implode($this->_errors, '
')); } }

如果您管理好了发布流程,如果一切正常,您应该重新定位到“问题”的表单上。使用已更改状态的默认消息,否则将显示错误。