if ($options['expanded'
]) { $builder->
setDataMapper($options['multiple'
] ?
new CheckboxListMapper() :
new RadioListMapper());
// Initialize all choices before doing the index check below.
// This helps in cases where index checks are optimized for non
// initialized choice lists. For example, when using an SQL driver,
// the index check would read in one SQL query and the initialization
// requires another SQL query. When the initialization is done first,
// one SQL query is sufficient.
$choiceListView =
$this->
createChoiceListView($choiceList,
$options);
$builder->
setAttribute('choice_list_view',
$choiceListView);
// Check if the choices already contain the empty value
// Only add the placeholder option if this is not the case
if (null !==
$options['placeholder'
] && 0 === \
count($choiceList->
getChoicesForValues([''
]))) { $placeholderView =
new ChoiceView(null, '',
$options['placeholder'
],
$options['placeholder_attr'
]);
// "placeholder" is a reserved name
$this->
addSubForm($builder, 'placeholder',
$placeholderView,
$options);
}