簡體   English   中英

在 Prestashop 1.7 模塊中添加下拉菜單

[英]Adding a dropdown menu in Prestashop 1.7 module

我是 Prestashop 1.7 的初學者,我想在我的橫幅模塊中添加一個下拉 select 部分到 select 打開橫幅鏈接的方式。

但是選擇的值永遠不會傳遞給 HTML,下面的代碼是通過但下面的不是,你能幫幫我嗎? [在此處輸入圖片描述][1]

array(
                        'type' => 'text',
                        'lang' => true,
                        'label' => $this->trans('Banner description', array(), 'Modules.Banner.Admin'),
                        'name' => 'BANNER_DESC',
                        'desc' => $this->trans('Please enter a short but meaningful description for the banner.', array(), 'Modules.Banner.Admin')
                    )
array(
                        'type' => 'select', //select
                        'lang' => true,
                        'label' => $this->trans('Banner tab', array(), 'Modules.Banner.Admin'),
                        'name' => 'BANNER_TAB',
                        'required'=>'true',
                        'options' => array(
                            'query' => array(
                                array('key' => '_blank', 'name' => 'New tab'),
                                array('key' => '_self', 'name' => 'Same tab'),
                            ),
                            'id' => 'key',
                            'name' => 'name'
                        ),
                        
                        'desc' => $this->trans('Please select the way to open the link.', array(), 'Modules.Banner.Admin')
                    )

這是它在后台的外觀:這里

您不僅需要在表單中添加一個新字段,還需要處理從中保存數據。

看幾個例子: https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L122

請注意模塊作者如何設法保存表單中的每個配置字段。 這是你需要做的。

如果您想訪問視圖中的數據,則必須傳遞它: https://github.com/PrestaShop/ps_featuredproducts/blob/dev/ps_featuredproducts.php#L244

也許在添加新字段后,您忘記處理保存 + 傳遞給視圖?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM