Translate select options in Symfony2 class forms

前端 未结 4 1598
孤城傲影
孤城傲影 2020-12-08 10:00

I\'m using a class form in Symfony2 Beta3 as follows:

namespace Partners\\FrontendBundle\\Form;

use Symfony\\Component\\Form\\AbstractType;
use Symfony\\Com         


        
4条回答
  •  失恋的感觉
    2020-12-08 10:48

    CptSadface's answer was what helped me with translating my entity choices.

    $builder
        ->add(
            'authorizationRoles',
            null,
            [
                'label' => 'app.user.fields.authorization_roles',
                'multiple' => true,
                'choice_label' => 'name', // entity field storing your translation key
                'choice_translation_domain' => 'messages',
            ]
        );
    

提交回复
热议问题