问题
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?
来源:https://stackoverflow.com/questions/16479052/symfony2-translate-form-entity-property