I'm using Symfony 2.3 with "a2lix/translation-form-bundle and sonataAdmin bundle
composer.json
"sonata-project/admin-bundle": "dev-master",
"sonata-project/doctrine-orm-admin-bundle": "dev-master",
"sonata-project/easy-extends-bundle": "dev-master",
"sonata-project/user-bundle": "dev-master",
"sonata-project/media-bundle": "2.2.*@dev",
"gedmo/doctrine-extensions": "2.3.*@dev",
"stof/doctrine-extensions-bundle": "~1.1@dev",
"a2lix/i18n-doctrine-bundle": "0.*@dev",
"a2lix/translation-form-bundle": "1.*@dev"
config.yml
framework:
default_locale: sl
translator: { fallback: %locale% }
stof_doctrine_extensions:
default_locale: %locale%
orm:
default:
sluggable: true
timestampable: true
blameable: ~
translatable: true
loggable: ~
softdeleteable: ~
uploadable: ~
a2lix_i18n_doctrine:
manager_registry: doctrine
a2lix_translation_form:
locales: [sl, sr, de, hr, hu]
default_required: true
manager_registry: doctrine
templating: "A2lixTranslationFormBundle::default.html.twig"
With this configuration I can show form in sonata admin with locales sl, sr, de, hr and hu. Data are also successfully stored in database. Here is a tricky way. If I add "en" locale to locales - locales: [en, sl, sr, de, hr, hu], then form throws me an error:
ContextErrorException: Notice: Undefined index: translationClass in /home/john/symfony/vendor/a2lix/translation-form-bundle/A2lix/TranslationFormBundle/TranslationForm/GedmoTranslationForm.php line 57
This happens only if I add en locale. Any other locales works fine. I have no idea what is wrong. Any tips?
Edit:
I figure ou what was wrong but this leads to another problem. If I add locales in a2lix_translation_form like [en, sr, de, hr, hu] (change sl with en) then it works. I think this is because my default locale is sl. My form mapper now looks like:
$formMapper
->add("name")
->add("description")
->add("starttime")
->add('translations', 'a2lix_translations_gedmo', array( // Use the old gedmo strategy
'translatable_class' => 'repincln\CoreBundle\Entity\ProfileTranslation',
));
Here begins the problem. If I fill out all fields, then in locale sl is stored english translation. sl translation is not stored anywhere. I suppose that first two fields (not in translation tabs) is sl locale (because in config.yml is default_locale:sl).
Is there any explanation for that?
Make sure that you have the Translation Resource/File Names and Locations set:
http://symfony.com/doc/current/book/translation.html#book-translation-resource-locations