2017-09-03 55 views
1

中翻译choice_label如何在字符串中的var内转换entityType字段的choice_label?symfony entityType在var

$builder->add('shippingAddress', EntityType::class, array(
        'class' => 'LilWorksStoreBundle:Address' , 
        'choice_label' => function ($obj) { 
         return "String to translate with " . $obj->getName() ; 
        }, 
        'query_builder' => function (EntityRepository $er) use ($customer) { 
         return $er->createQueryBuilder('a') 
          ->leftJoin('LilWorksStoreBundle:Customer', 'c', 'WITH', 'c.id = a.customer') 
          ->where('c.id = :id') 
          ->setParameter('id',$customer->getId()) 
          ; 
        }, 
        'required' => false , 
        'mapped'=> true, 
        'expanded' => true , 
        'multiple' => false, 
        'translation_domain' => 'my_translation' 
       )); 

回答

0

试试这个方法:

'choice_translation_domain' => 'my_translation' 
+0

谢谢...但我怎么能有一些变种为transchoice? –