如何在表单字段prestaShop表单助手中添加自定义ID

问题描述 投票:0回答:1

嗨伙计们,我新手prestashop和我正在开发一个模块,在后台我使用帮助形式,我如何在我的模块的配置页面中添加id到我的表单字段,目前我需要添加类或id到类别树形式帮助器?我尝试跟随,但它不起作用?

array(
                    'type' => 'categories',
                    'label' => 'tree categories',
                    'name' => 'type_categories',
                    'class'=>'cat-test',
                    'tree' => array(
                        'root_category' => 2,
                        'id' => 'id_category',
                        'name' => 'name_category',
                        'selected_categories' => array(),
                    )
                ),
prestashop-1.6
1个回答
0
投票

您无法使用帮助程序表单在树上管理ID / Class。

所以你可以在模板上做到:

PHP:

public function getContent(){ return $this->renderCategories(); }

protected function renderCategories() {
   $root = Category::getRootCategory();
    $selected_cat = array();
    $tree = new HelperTreeCategories('categories-treeview');
    $tree->setUseCheckBox(true)
            ->setAttribute('is_category_filter', $root->id)
            ->setRootCategory($root->id)
            ->setSelectedCategories($selected_cat)
            ->setUseSearch(true);
    $this->smarty->assign(array(
        'tree' => $tree->render(),
        'formlink' => $this->context->link->getAdminLink('AdminModules', false)
        . '&configure=' . $this->name
        . '&tab_module=' . $this->tab
        . '&module_name=' . $this->name
        . '&token=' . Tools::getAdminTokenLite('AdminModules')
    ));
    return $this->display(__FILE__, '/views/templates/admin/configure.tpl');
}

TPL:

<div class="panel col-lg-12" >
<form id="module_form" class="defaultForm form-horizontal" action="{$formlink}" method="post" novalidate="">
    <h3><i class="icon icon-cogs"></i>Category</h3><br/>

                            <!--TREE-->
    <div class="form-group">
        <div class="col-lg-2">
            <span class="pull-left">
                <label class="control-label" for="category_block" id="Category"> 
                    Categories : 
                </label>
            </span>
        </div>
        <div class="col-lg-9">
            <div id="YOUR ID" class="YOUR CLASS">
                {$tree}                  
            </div>
        </div>
    </div>

    <div class="panel-footer col-lg-12" id="footer-submit"  >
         <!--SUBMIT submitAddRule-->
        <button type="submit" value="1" id="submitCatThe" name="submitCatThe" class="btn btn-default pull-right"/>
        <i class="process-icon-save">
        </i>
        Save

    </div>
</form>
</div>
© www.soinside.com 2019 - 2024. All rights reserved.