[英]Tools::isSubmit() Prestashop not working
I am new to prestashop and module development. 我是prestashop和模块开发的新手。 I was practicing a module which allows users to submit comment on a product.
我正在练习一个模块,该模块允许用户提交有关产品的评论。 But there is an issue with form submission.
但是表单提交存在问题。 I think.
我认为。
Below is the code I tried.(Only methods of interest) 下面是我尝试过的代码。(仅感兴趣的方法)
BulkyEdit.php 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 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 logs failure. $ stat记录失败。
Edit : BULKYEDIT_TESTVAL logs Forms post failure 编辑:BULKYEDIT_TESTVAL记录表单发布失败
if(isset($_POST['comment_submit_form']))
{
Configuration::updateValue('BULKYEDIT_TESTVAL',$_POST);
}
else{
Configuration::updateValue('BULKYEDIT_TESTVAL','Forms post failure');
}
Any help is highly appreciated. 非常感谢您的帮助。
No Issues with the code.Everything works fine. 代码没有问题。一切正常。 Actually the code I wrote for the first time was different and I was using a wrong name in Tools::isSubmit('submit').But after I made changes prestashop kept using the cached files so I could not able to get the desired results according to my latest edits.
实际上我第一次编写的代码是不同的,并且我在Tools :: isSubmit('submit')中使用了错误的名称,但是在进行更改后,prestashop继续使用缓存的文件,所以我无法获得预期的结果根据我的最新编辑。
I then disabled cache and enabled Developer Mode following the instructions here. 然后,我按照此处的说明禁用了缓存并启用了开发人员模式。
http://blog.belvg.com/enabling-error-output-in-prestashop.html http://blog.belvg.com/enabling-error-output-in-prestashop.html
And everything was working like a charm. 一切都像魅力一样运作。 So, When developing.
因此,在开发时。 enable Developer mode on so you can see results of your latest edits.
启用开发人员模式,以便您可以查看最新编辑的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.