Symfony2 translate form entity property

2019-08-04 17:05发布

I have a symfony2 form for edit users. My users has roles and you can select multiple roles for one user.

In my form I display the UserRoles entity:

$builder->add( 'rolesAsObject', 'entity', array( 'label' => 'roles', 'class' => 'AcmeUserBundle:UserRoles', 'multiple' => true, 'property' => 'name' ) );

This works correctly, but the name property is just a number, an id for a language key, because I would like to translate the name of the roles.

Is this possible to call a function somehow on the property?

0条回答
登录 后发表回答