2014-11-21 113 views
0

我翻译我的实体与A2LiX I18n学说和编辑/使用A2lixTranslationBundle创建它,但我有onmany和manytomany关系的问题。A2lix关系许多与entites

Product.php

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

我有不可翻译的相关信息如电话,地址Base.php ..和BaseTranslation.php可翻译信息,如姓名和描述。 我想将其添加到我的产品表单中以选择一个或多个基地,但我无法访问可翻译的名称,只能查看产品中的信息。

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

这工作,因为城市是Base.php

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

这并不是因为名称是BaseTranslation.php。 这是一种访问名称的方式,可以在我的“产品”表单上用checbox显示所有可指定基地的名称?

回答

0

尝试

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

由于解释上http://a2lix.fr/bundles/translation-form/#bundle-additional,目前的实施需要,对当前的语言环境中存在的翻译。

+0

谢谢,如果当前本地doesen't的翻译存在,我使用$ translation变量为本地用户获取默认语言。 – 2014-11-27 23:51:44