symfony/symfony — pull request #8112 by bamarni (2013-05-21 15:22:46+00:00)
Title: [WIP][2.4][Form] Add option "widget" to ChoiceType

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

- [ ] add / fix tests
- [ ] submit changes to the documentation
- [ ] update php templates and twig table layout

I've implemented the behavior described in #6602.

### Choice

- About the ```text``` widget, I think it makes more sense to ask for the label instead of the value,

- Also, does ```choice_widget_select``` now fit better than ```choice_widget_collapsed```?

### Doctrine

- For the original entity_id use case, it'd simply mean setting the ```property``` option to ```id```.

``` php
add('field', 'entity', array(
'class' => 'MyBundle:Product',
'widget' => 'text',
'property' => 'id',
));
```

Then the choice list won't be loaded in advance but validated on the fly.

I had to add 2 methods in the choiceList for this feature (getChoicesForLabels and the reversed one). What do you think about the approach? cc @bschussek