symfony/symfony — pull request #10261 by iamluc (2014-02-14 11:34:11+00:00)
Title: [Form] Accept a closure as label formatter in an ObjectChoiceList

Sometimes, the __toString() method is not enough to format the labels of a choices list because you want to show differents labels on differents FormType, or because you need externals informations.

This commit adds support to closure to fix this.

ie.
```php
add('name')
->add('country', 'entity', array(
'class' => 'MyProject\Bundle\DemoBundle\Entity\Country',
'property' => function ($country) use ($localizator) {
return $country->getName().' ('.$localizator->translate($country->getName()).')';
}
)
)
;
}
```

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |