Troubleshooting form submission in PrestaShop's hookDisplayAdminProductsExtra module

29 Views Asked by At

I'm attempting to create a module in PrestaShop that adds a field in the hookDisplayAdminProductsExtra. However, the submit method is not executed when I submit the form.

public function hookDisplayAdminProductsExtra()
{
    if (Tools::isSubmit("submitextra")) {
        $id_product = (int)Tools::getValue('id_product');
        $extraInfo = Tools::getValue('extra');
        $sql = 'UPDATE psdev_product SET produto_extra = "' . pSQL($extraInfo) . '"
            WHERE id_product = ' . (int) $id_product;
        Db::getInstance()->execute($sql);
    }

    return $this->display(__FILE__, "views/templates/hook/displayAdminExtra.tpl");
}    

Here's the TPL file:

<form action="{$link->getAdminLink('AdminProducts')|escape:'html':'UTF-8'}&action=saveExtraInfo" method="post">
  <label for="extra">Extra Info</label>
  <input type="text" name='extra' class="form-control" />
  <button type="submit" name='submitextra'>Save</button>
</form>    

This module works perfectly when used in a different hook. I suspect the issue lies in the fact that I should be using the submit input value of the page, but I'm struggling to find the correct method.

0

There are 0 best solutions below