A2lix relations manytomany with entites

183 views Asked by At

I translate my entities with A2LiX I18n Doctrine and edit/create it with A2lixTranslationBundle, but I have a problem with ontomany and manytomany relations.

Product.php

/**
* @ORM\ManyToMany(targetEntity="hello\PlatformBundle\Entity\Base", cascade={"persist"})
*/
private $bases;

I have a Base.php with non-translatable infos like phone, address .. and a BaseTranslation.php with translatable informations like name and description. I would like to add it to my Product form to select one or more bases, but I can't access to the translatable name, only the informations in Product.

->add('base',         'entity', array(
            'class'     => 'HelloPlatformBundle:Base',
            'property'  => 'city',
            'multiple'  => true,
            'expanded'  => true,
            ))

This works because city is in Base.php

->add('base',         'entity', array(
            'class'     => 'HelloPlatformBundle:Base',
            'property'  => 'name',
            'multiple'  => true,
            'expanded'  => true,
            ))

This not because name is in BaseTranslation.php. This is a way to access name to display all the disponible base's names with checbox on my Product form ?

1

There are 1 answers

1
webda2l On BEST ANSWER

Try

->add('base', 'a2lix_translatedEntity', array(
     'class'     => 'HelloPlatformBundle:Base',
     'translation_property'  => 'name',
     'multiple'  => true,
     'expanded'  => true,
 ))

As explain on http://a2lix.fr/bundles/translation-form/#bundle-additional, current implementation need that translations exist for the current locale.