2014-11-21 109 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