sonata-project/SonataAdminBundle — pull request #2484 by lutangar (2014-10-10 15:32:08+00:00)
Title: List editable choice

Add x-editable support for (non multiple) choice in lists, this feature was once mentioned in #1867 by @EmmanuelVella and also requested in #2269.
Multiple choice may require more work though.

First thing was to move the `x-editable` types mapping to the **parameters**, *imho* its was pretty annoying to have it hard-coded in the twig extension. Especially if you need to add more editable types in your project.

The behaviour is quite similar to the way `booleans` were handled.
```
protected function configureListFields(ListMapper $list)
{
$list
->add('status', 'choice',
[
'editable' => true,
'choices' => ['Status1' => 'Alias1', 'Status2' => 'Alias2'],
'catalogue' =>'admin'
]
);
}
```

The tricky part is to transform the provided **choices** options into something that can be fed to the `x-editable` widget :
### Choices
```
['Status1' => 'Alias1', 'Status2' => 'Alias2']
```
### X-editable choices
```
[['value' => 'Status1', 'text': 'Alias1'], ['value' => 'Status2', 'text': 'Alias2']]
```
This is working pretty well for `enum` like `array`, but It might be interesting to handle more inputs, like `ArrayCollection`.
How would you guys do to handle such cases?

Any feedbacks welcome.