Tools::isSubmit() Prestashop 不工作

Tools::isSubmit() Prestashop not working

我是 prestashop 和模块开发的新手。我正在练习一个允许用户提交对产品评论的模块。但是表单提交有问题。我觉得。

下面是我试过的代码。(只有感兴趣的方法)

BulkyEdit.php

public function install()
 {
    if (!parent::install() )
        return false;

        //Registering the hook.
        $this->registerHook('displayProductTabContent');
        return true;
}
public function hookDisplayProductTabContent($params)
{
   //Using hook displayProductTabContent.

   $this->processCommentPublish();
   return $this->display(__FILE__,'displayProductTabContent.tpl');
}
private function processCommentPublish()
{
   $stat = Tools::isSubmit('comment_submit_form');
   if($stat)
   {
     $stat = "submit success";
   }
   else $stat = "failure";
    Configuration::updateValue('BULKYEDIT_TESTVAL',$stat);
}

displayProductTabContent.tpl

<form action="" method="post">
    <div class="form-group">
        <label for="name">Name</label>
        <input type="text" placeholder="Tell us your name" name="name"/>
    </div>

    <div class="form-group">
        <label for="comment">Your comment</label>
        <input type="text" placeholder="Tell us your name" name="comment"/>
    </div>
    <div class="form-group">
        <input class="btn btn-primary" type="submit" name="comment_submit_form" value="Publish"  />
    </div>
</form>

$stat 记录失败。

编辑:BULKYEDIT_TESTVAL 记录表单 post 失败

if(isset($_POST['comment_submit_form']))
{
    Configuration::updateValue('BULKYEDIT_TESTVAL',$_POST); 
}
else{
    Configuration::updateValue('BULKYEDIT_TESTVAL','Forms post failure');
}

非常感谢任何帮助。

没有问题 code.Everything 工作正常。实际上,我第一次写的代码是不同的,我在 Tools::isSubmit('submit') 中使用了错误的名称。但是在我进行更改后,prestashop 继续使用缓存文件,所以我无法获取根据我最近的编辑得到想要的结果。

然后我按照此处的说明禁用了缓存并启用了开发者模式。

http://blog.belvg.com/enabling-error-output-in-prestashop.html

一切都很顺利。所以,在开发的时候。启用开发人员模式,以便您可以查看最新编辑的结果。