interface ChoiceListFactoryInterface
Creates {@link ChoiceListInterface} instances.
ChoiceListInterface | createListFromChoices(iterable $choices, callable|null $value = null) Creates a choice list for the given choices. | |
ChoiceListInterface | createListFromLoader(ChoiceLoaderInterface $loader, callable|null $value = null) Creates a choice list that is loaded with the given loader. | |
ChoiceListView | createView(ChoiceListInterface $list, array|callable|null $preferredChoices = null, callable|null $label = null, callable|null $index = null, callable|null $groupBy = null, array|callable|null $attr = null) Creates a view for the given choice list. |
Creates a choice list for the given choices.
The choices should be passed in the values of the choices array.
Optionally, a callable can be passed for generating the choice values. The callable receives the choice as first and the array key as the second argument.
iterable | $choices | The choices |
callable|null | $value | The callable generating the choice values |
ChoiceListInterface | The choice list |
Creates a choice list that is loaded with the given loader.
Optionally, a callable can be passed for generating the choice values. The callable receives the choice as first and the array key as the second argument.
ChoiceLoaderInterface | $loader | The choice loader |
callable|null | $value | The callable generating the choice values |
ChoiceListInterface | The choice list |
Creates a view for the given choice list.
Callables may be passed for all optional arguments. The callables receive the choice as first and the array key as the second argument.
If no callable is passed, the labels will be generated from the choice keys. The view indices will be generated using an incrementing integer by default.
The preferred choices can also be passed as array. Each choice that is contained in that array will be marked as preferred.
The attributes can be passed as multi-dimensional array. The keys should match the keys of the choices. The values should be arrays of HTML attributes that should be added to the respective choice.
ChoiceListInterface | $list | The choice list |
array|callable|null | $preferredChoices | The preferred choices |
callable|null | $label | The callable generating the choice labels |
callable|null | $index | The callable generating the view indices |
callable|null | $groupBy | The callable generating the group names |
array|callable|null | $attr | The callable generating the HTML attributes |
ChoiceListView | The choice list view |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
https://api.symfony.com/4.1/Symfony/Component/Form/ChoiceList/Factory/ChoiceListFactoryInterface.html