我跟着this tutorial on creating a custom module for a new tab and input in the back office在prestahop中添加製表符和後臺產品 - 如何正確保存輸入?
我什麼都不想用語言做 - 我有一個簡單的文本輸入,其中用戶將輸入的INT。
在有我們更新hookActionProductUpdate方法教程:
public function hookActionProductUpdate($params)
{
// get the lines
// store the new field
$id_product = (int)Tools::getValue('id_product');
if(!Db::getInstance()->update('number_lines', array('number_lines'=> pSQL(Tools::getValue('number_lines'))).' AND id_product = ' .$id_product))
$this->context->controller->_errors[] = Tools::displayError('Error: ').mysql_error();
}
當我點擊「保存&留」沒有任何反應。
我.tpl正顯示出它是這樣的:
<div class="col-lg-1">
<input type="text" name="number_lines" id="number_lines" value="{$number_lines|htmlentities}" />
</div>
任何幫助,將不勝感激。
總體目的只是讓用戶輸入數字並將其保存到產品後臺數據庫中的文本字段。
要顯示後臺辦公室中的行數,是通過{$ number_lines}以.tpl中的適當方式訪問它? – Hanny
如果已經指定了Smarty變量,是的,那很好,但是認爲您需要將其修改爲'{$ number_lines | intval}' –