我在名为“说明页脚”的类别中添加了一个额外的可翻译字段,但我在该字段上使用所见即所得编辑器时遇到问题。 我使用 Prestashop 1.7.8.8 和 Elementor 插件,有 4 种活动语言
use PrestaShopBundle\Form\Admin\Type\FormattedTextareaType;
use PrestaShopBundle\Form\Admin\Type\TranslatableType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
public function hookActionCategoryFormBuilderModifier(array $params)
{
/** @var \Symfony\Component\Form\FormBuilder $formBuilder */
$formBuilder = $params['form_builder'];
$locales = $this->get('prestashop.adapter.legacy.context')->getLanguages();
$formBuilder->add('description_footer',
// cf. https://devdocs.prestashop.com/1.7/development/components/form/types-reference/
TranslatableType::class,
[
'label' => $this->l('Description footer'),
'type' => FormattedTextareaType::class,
'required' => false,
'locales' => $locales
]
);
$category = new Category((int)$params['id']);
$params['data']['description_footer'] = $category->description_footer;
$formBuilder->setData($params['data']);
}
我明白了
使用类 TranslateType::class 代替 TranslatableType::class 解决了
$formBuilder->add('description_footer',
// cf. https://devdocs.prestashop.com/1.7/development/components/form/types-reference/
TranslateType::class,
[
'label' => $this->l('Descrizione footer'),
'type' => FormattedTextareaType::class,
'required' => false,
'locales' => $locales,
'hideTabs' => false,
]
);