1

我已将Formatter(使用 CKeditor)插入到'content'我的 SonataAdmin课程中的一个字段中。这'content'也有一个翻译,可以通过'a2lix_translations_gedmo'翻译类型进行编辑。我也一直在尝试将 CKeditor 添加到此字段,但它会在我尝试设置的任何配置中引发异常。

谷歌对此一无所知,SO 也是如此。我还查看了Sonata News Bundle源(在哪里sonata_formatter_type实现),但没有可用的翻译。

我的格式化程序字段:

->add('content', 'sonata_formatter_type', [
    'label'                => "Content",
    'event_dispatcher'     => $formMapper->getFormBuilder()->getEventDispatcher(),
    'format_field'         => 'contentFormatter',
    'source_field'         => 'rawContent',
    'ckeditor_context'     => 'my_config',
    'source_field_options' => [
        'attr' => [
            'class' => 'span10', 'rows' => 10
        ]
    ],
    'listener'             => TRUE,
    'target_field'         => 'content'
])

我的翻译字段:

->add('translations', 'a2lix_translations_gedmo', [
    'label' => "Управление локализациями",
    'translatable_class' => 'AppBundle\Entity\Article',
    'fields' => [
        'content' => [
            'locale_options' => [
                'ru' => [
                    'label' => 'Контент'
                ]
            ]
        ]
    ]
])

也许有人知道如何添加'sonata_formatter_type'到这种该死的'a2lix_translations_gedmo'类型(或'a2lix_translations')?

4

1 回答 1

2

'a2lix_translations_gedmo' or 'a2lix_translations' depends of the translation strategy chosen. Gedmo strategy is discouraged and you shoud use a more recent translation strategy like the KnpLabs that I recommend. https://github.com/KnpLabs/DoctrineBehaviors#translatable

Othewise, see https://github.com/a2lix/TranslationFormBundle/issues/177#issuecomment-94949480

于 2015-05-29T12:17:42.087 回答