Closed
Description
A placeholder
option value should be preferred to empty_value
if both are
set in a choice type.
An example of a choice type having values for both options is a form class
which declares a LexikFormFilterBundle filter_boolean
type field in a Symfony
2.8 project:-
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('foo', 'filter_boolean', array(
'choices' => array( ... ),
'placeholder' => 'Some Placeholder',
))
But the Lexik filter_boolean type defines a default empty_value
option:-
public function getParent()
{
return 'choice';
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setDefaults(array(
'required' => false,
'choices' => array(
self::VALUE_YES => 'boolean.yes',
self::VALUE_NO => 'boolean.no',
),
'empty_value' => 'boolean.yes_or_no',
The result is that the placeholder
is ignored and empty_value
is used.
Clearly the Lexik type needs to be updated, but this issue causes trouble for
developers who update their application code while waiting for the project
dependencies to catch-up.
PR follows.