translation-form with default entity translations not found translation-form with default entity translations not found symfony symfony

translation-form with default entity translations not found


Here is the working example from my current project how to use DoctrineExtension from KNP (I know this doesn't answer the question, look at the comments above).

composer.json:

"knplabs/doctrine-behaviors": "dev-master","a2lix/translation-form-bundle" : "dev-master"

config.yml:

imports:    ...    - { resource: ../../vendor/knplabs/doctrine-behaviors/config/orm-services.yml }framework:    translator:        fallback: "%locale%"    ...a2lix_translation_form:    locale_provider: default    locales: [ru, en]    default_locale: ru    required_locales: [ru]    manager_registry: doctrine    templating: "@SLCore/includes/translation.html.twig" # if you want to use your own template 

Entities:Product

use Knp\DoctrineBehaviors\Model\Translatable\Translatable;class Product{    use Translatable;    // other fields which should not be translated    // $translations field alredy has been created and mapped by DE

ProductTranslation (DE requires this entity):

use Knp\DoctrineBehaviors\Model\Translatable\Translation;class ProductTranslation{    use Translation;    // fields that should be translated    // e.g. $title, $description (id, locale, translatable fields already have been created by Translation trait, mapped by DE)

ProductType form:

->add('translations', 'a2lix_translations', [/* other options go here */])

form.html.twig:

{% block javascripts %}    {{ parent() }}    <script type="text/javascript" src="{{ asset('bundles/a2lixtranslationform/js/a2lix_translation_bootstrap.js') }}"></script>{% endblock %}...{{ form_widget(form.translations) }}

I know this is not an interesting example, but it works.