Skip to content

Commit 342ad02

Browse files
committed
Fix choice keys and values for custom field types
Choices labels are defined as the keys of the array as of Symfony 3 (see symfony/symfony#14050).
1 parent dbee0be commit 342ad02

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

form/create_custom_field_type.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ for form fields, which is ``<BundleName>\Form\Type``. Make sure the field extend
3333
{
3434
$resolver->setDefaults(array(
3535
'choices' => array(
36-
'm' => 'Male',
37-
'f' => 'Female',
36+
'Male' => 'm',
37+
'Female' => 'f',
3838
)
3939
));
4040
}
@@ -384,7 +384,7 @@ configuration::
384384
public function configureOptions(OptionsResolver $resolver)
385385
{
386386
$resolver->setDefaults(array(
387-
'choices' => $this->genderChoices,
387+
'choices' => array_flip($this->genderChoices),
388388
));
389389
}
390390

0 commit comments

Comments
 (0)