Hi Romain,
Please take a look at this proposal:
https://github.com/symfony/symfony/issues/4067
Regards,
M
On Monday, April 16, 2012 4:10:33 PM UTC+2, Romain Geissler wrote:
>
> Hi,
>
> The current Symfony\Component\Form\Extension\Core\ChoiceList
> \ObjectChoiceList does provide two way to specify labels for an
> object : using a label path or using the objet __toString magic
> method. However this doesn't fit my need.
>
> Simple example : I want the to expose a choice list of Doctrine
> entities, a person for example with a title (Mr., Mrs, Miss), a
> firstname and a lastname. So i want to be able to translate the title
> using the session locale (in French 'Miss' becomes 'Mlle' for
> example). Neither the label path nor the __toString method are context
> aware (ie those can't translate a person title using the session
> locale). The best way to handle that would be using a closure or a
> class object like this :
>
> function ($person) use ($translator)
> {
> return $translator->trans($person->getTitle()).' '.$person-
> >getFirstName().' '.$person->getLastName();
> }
>
> or
>
> class PersonFormatter extends ObjectFormatter
> {
> protected $translator;
>
> public function __construct($translator)
> {
> $this->translator = $translator;
> }
>
> public format($person)
> {
> return $translator->trans($person->getTitle()).' '.$person-
> >getFirstName().' '.$person->getLastName();
> }
> }
>
>
> Question : I want to add this closure feature to ObjectChoiceList. May
> I replace the old labelPath with a closure (as you simply can
> reproduce labelPath with a closure) causing a backward compatibility
> break or should i add the closure feature as a new way to define
> labels ?
>
> Romain Geissler
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en