繁体   English   中英

工具:: 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记录表单发布失败

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

非常感谢您的帮助。

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

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

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

一切都像魅力一样运作。 因此,在开发时。 启用开发人员模式,以便您可以查看最新编辑的结果。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM