简体   繁体   中英

Tools::isSubmit() Prestashop not working

I am new to prestashop and module development. 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

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 logs failure.

Edit : BULKYEDIT_TESTVAL logs Forms post failure

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.

I then disabled cache and enabled Developer Mode following the instructions here.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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