Create custom template list field for title and name with SonataUserBundle User Entity GENDER constants in SonataAdminBundle

0 Flares Twitter 0 Facebook 0 LinkedIn 0 0 Flares ×

The SonataUserBundle UserInterface uses the following GENDER constants:

We will use the gender to determine the title of a User and prefix it to the full name. To set a custom template in my UserAdmin class we configure the field:

The following custom template uses older Twig Syntax to retrieve the constants:

The following version is recommended and uses Twig Syntax (e.g. “ternary operator”) since 1.12.0:

 

Web Deviloper