satboy78
satboy78

Reputation: 317

issue with sonata admin + a2lix + gedmo translatable

I'm trying to use sonata admin + a2lix + gedmo translatable to translate my entities.

Unfortunately it doesn't work, because I expect to see my translatable fields in the form, while in my backend I can see this "field - content" :

field-content

I've followed this tutorials:

http://a2lix.fr/bundles/translation-form/

http://www.elao.com/blog/symfony-2/doctrine-2/how-to-manage-translations-for-your-object-using-sonataadminbundle.html

and the documentation of the bundles.

Here you can find all the code I wrote: https://gist.github.com/itxavia/8416920

I'm pretty sure that the translatable annotation used is good, because I've tried to use those entities with PugX (another "admin generator") and all work fine... but I need sonata admin because it has got some features that PugX doesn't have so I'd like to get this code working.

Do you have experience with sonata admin, a2lix and gedmo to get translatable entities?

Can you please give me some hints?

Thanks a lot

Best regards

Upvotes: 4

Views: 2444

Answers (1)

brgs
brgs

Reputation: 806

Alright, I finally fixed it. It seems the v2 of the a2lix/translation-form-bundle doesn't support the old gedmo strategy, you would have to use wip 2.4.0 for it to work properly, but there isn't stofDoctrineIntegration bundle yet for that, so.. To get this working, you need to use 1.* branch of the a2lix/translation-form-bundle, add this to your composer.json:

"a2lix/translation-form-bundle": "1.*@dev"

Then in your Sonata admin class where you would like to use translations:

$formMapper
    ->add('translations', 'a2lix_translations_gedmo', array(   // Use the old gedmo strategy
        'translatable_class' => 'Your\Translatable\Entity\Class', 
));

Took me a while to figure this out, but it works great!

Upvotes: 5

Related Questions