如何添加"保存"和"保存&留"新产品选项卡上的按钮Prestashop 1.6

时间:2017-03-02 23:22:15

标签: php module prestashop prestashop-1.6

美好的一天。 我在Prestashop 1.6中编写了一个简单的模块,它在后台的产品页面上添加了一个新选项卡,其中包含一些新的产品属性。 我已经添加了新标签和我需要的内容,但我想插入标准" save"和"保存&留"纽扣。查看helper form class 可能是我可以使用的东西,但是如何?我在哪里以及如何使用它?

这是钩子模块代码的一部分:

public function prepareNewTab()
{

    $this->context->smarty->assign(array(

        'isThisProductNew' => $this->getisThisProductStillNew((int)Tools::getValue('id_product')),
        'howManyDays' => Configuration::get('PS_NB_DAYS_NEW_PRODUCT'),
        'date_add' => $this->getProductDateAdd((int)Tools::getValue('id_product')),
        'strtotime_days' =>$this->strtotime_date()
    ));


}


    public function hookDisplayAdminProductsExtra(){
        $this->prepareNewTab();

        return $this->display(__FILE__, 'views/templates/admin/newProductsTab.tpl');
    }

我确定我不必在tpl 中从头开始构建按钮,有人能引导我走向正确的方向吗?我没有见过任何例子(我的意思是针对这个案例)。

1 个答案:

答案 0 :(得分:0)

在自定义tpl文件中,为提交按钮添加以下代码:

<button type="submit" name="submitAddproduct" class="btn btn-default pull-right" disabled="disabled"><i class="process-icon-loading"></i> {l s='Save'}</button>
    <button type="submit" name="submitAddproductAndStay" class="btn btn-default pull-right" disabled="disabled"><i class="process-icon-loading"></i> {l s='Save and stay'}</button>  

默认情况下,您的表单会在表单下显示,以便每当用户访问任何这些按钮时,系统将根据按钮名称识别操作并相应地工作。