Closed
Description
I've updated to 2.7 and changed my choice types to use choices_as_values
.
Most of my choices are simple "No" or "Yes". But they must not be preselected - the user is forced to choose. That is why none of my radio buttons is initially checked.
I tried this with 2.7:
$builder->add('aberdeenBlind', 'choice', array(
'choices' => array(
'Ja' => true,
'Nein' => false
),
'choices_as_values' => true,
'expanded' => true,
'required' => true
))
Unfortunately the second radio button (false => 'Nein') is preselected. This also happens when flipping the order of the choices
. The false
choice is always preselected.
I played around with other options e.g. placeholder
, empty_*
etc. but then I recognized:
This only seems to happen when using boolean
values. The following example would not preselect any value:
$builder->add('aberdeenBlind', 'choice', array(
'choices' => array(
'Ja' => 'Y', // or '1'
'Nein' => 'N' // or '0'
),
'choices_as_values' => true,
'expanded' => true,
'required' => true
))
Possibly related: