1

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

Damaged Organic
  • 8,175
  • 6
  • 58
  • 84

1 Answers1

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

webda2l
  • 6,686
  • 2
  • 26
  • 28
  • Yes, solution from GitHub works just fine. Thank you! I think I'll use KNP bundle in my next project, thanks for pointing it out as well. Cheers! – Damaged Organic May 30 '15 at 07:32