Prestashop 1.7 - Cms 页面类别上的 Bug FormBuilder

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

我编写了一个 Prestashop 模块来在 CMS 类别中添加两个字段,但渲染错误。

我的源代码:

<?php
class NewsSlider extends Module {
    public function hookActionCmsPageCategoryFormBuilderModifier(array $params) {
        $formBuilder = $params['form_builder'];
        $locales = $this->get('prestashop.adapter.legacy.context')->getLanguages();

        $formBuilder->add($this->name.'_cover_lang',
            \PrestaShopBundle\Form\Admin\Type\TranslatableType::class,
            [
                'type' => \Symfony\Component\Form\Extension\Core\Type\FileType::class,
                'label' => $this->l('Image de couverture'),
                'options' => [
                    'required' => false,
                    'constraints' => [
                        'mimeTypes' => [
                            'image/png',
                            'image/jpeg'
                        ],
                        'mimeTypesMessage' => 'JPEG/PNG',
                    ]
                ],
                'required' => false,
            ]
        );

        $formBuilder->add($this->name.'_header_lang',
            \PrestaShopBundle\Form\Admin\Type\TranslateType::class,
            [
                'type' => \PrestaShopBundle\Form\Admin\Type\FormattedTextareaType::class,
                'label' => $this->l('Entête de la page'),
                'locales' => $locales,
                'hideTabs' => false,
                'required' => false
            ]
        );

        $languages = Language::getLanguages(true);
        foreach($languages as $lang){
            $content = $this->getCMSHeader($params['id'], $lang['id_lang'], $isCategory);
            if(is_string($content) && strlen($content)) {
                $params['data'][$this->name.'_header_lang'][$lang['id_lang']] = $content;
            }
        }

        $formBuilder->setData($params['data']);
    }
}
?>

您可以看到render here

我为 CMS 页面 (hookActionCmsPageFormBuilderModifier) 编写了完全相同的代码,并且它正在工作。为什么不一样?

module prestashop
1个回答
0
投票

我知道这个话题很旧,但我没有找到任何答案。你能分享你得到的模块吗?

© www.soinside.com 2019 - 2024. All rights reserved.