Sonata Admin - A2LiX Translation Field + Sonata Formatter Type

1.6k Views Asked by At

I've plugged Formatter (with CKeditor) to the 'content' field in one of my Sonata's Admin classes. This 'content' also has a translation, that's editable through 'a2lix_translations_gedmo' translations type. I've been trying to add CKeditor to this field as well, but it throws exceptions in any configuration I'm trying to set.

Google knows nothing about it, as well as SO. I've also looked in Sonata News Bundle sources (where sonata_formatter_type is implemented), but there are no translations available.

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

1

There are 1 best solutions below

1
On BEST ANSWER

'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