[英]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.