简体   繁体   English

Sonata管理员-A2LiX转换字段+ Sonata格式化程序类型

[英]Sonata Admin - A2LiX Translation Field + Sonata Formatter Type

I've plugged Formatter (with CKeditor) to the 'content' field in one of my Sonata's Admin classes. 我已经将Formatter (带有CKeditor)插入到Sonata的Admin类之一的'content'字段中。 This 'content' also has a translation, that's editable through 'a2lix_translations_gedmo' translations type. 'content'还具有翻译,可通过'a2lix_translations_gedmo'翻译类型进行编辑。 I've been trying to add CKeditor to this field as well, but it throws exceptions in any configuration I'm trying to set. 我也一直试图将CKeditor添加到此字段,但是它在我尝试设置的任何配置中都会引发异常。

Google knows nothing about it, as well as SO. Google对此一无所知。 I've also looked in Sonata News Bundle sources (where sonata_formatter_type is implemented), but there are no translations available. 我还查看了Sonata News Bundle的资源(实现了sonata_formatter_type资源),但是没有可用的翻译。

My Formatter field: 我的格式化程序字段:

->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'
])

My Translation fields: 我的翻译领域:

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

Maybe someone knows how to add 'sonata_formatter_type' to this damn 'a2lix_translations_gedmo' type (or 'a2lix_translations' )? 也许有人知道如何将'sonata_formatter_type'添加到该死的'a2lix_translations_gedmo'类型(或'a2lix_translations' )中?

'a2lix_translations_gedmo' or 'a2lix_translations' depends of the translation strategy chosen. “ a2lix_translations_gedmo”或“ a2lix_translations”取决于所选的翻译策略。 Gedmo strategy is discouraged and you shoud use a more recent translation strategy like the KnpLabs that I recommend. 不鼓励使用Gedmo策略,您应该使用更新的翻译策略,例如我建议的KnpLabs。 https://github.com/KnpLabs/DoctrineBehaviors#translatable https://github.com/KnpLabs/DoctrineBehaviors#translatable

Othewise, see https://github.com/a2lix/TranslationFormBundle/issues/177#issuecomment-94949480 否则,请参见https://github.com/a2lix/TranslationFormBundle/issues/177#issuecomment-94949480

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM