Question: i need to create a form with symfony that has an entity type, so this is im using

```
->add('assignee', 'entity', array(
           'label' => 'Assignee',
           'class'  => 'PortalBundle:TrnUser',
           'property' => 'username',
           ))

```

in the generated html it assigns userid as the option value, but i need the username as the option value. something like,

```
<option value="admin">admin</option>

```

how can i do this? please help. 

thanks..

Answer: 
You need data transformers. They help you to show data in form as you want.
There you can find all information about Data Transformers in Symfony2:

<http://symfony.com/doc/current/cookbook/form/data_transformers.html>
You could use the 'choice\_value' option with the name of the field you want to use instead of the id.

```
        $builder
        ->add('user', 'entity', [
            'class' => 'YourBundle\Entity\Locations',
            'property' => 'name',
            'choice_value' => 'name',
            'required' => true,
        ])

```