Skip to content

Commit 63e17af

Browse files
author
Yann Eugoné
committed
Merge pull request #5 from J-Ben87/master
Flip the EnumType choices to match option "choices_as_values"
2 parents 34e3e78 + 8d4b1ef commit 63e17af

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Form/Type/EnumType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function ($name) {
4343
->setDefault(
4444
'choices',
4545
function (Options $options) {
46-
return $this->enumRegistry->get($options['enum'])->getChoices();
46+
return array_flip($this->enumRegistry->get($options['enum'])->getChoices());
4747
}
4848
)
4949
;

Tests/Form/Type/EnumTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testEnumOptionValid()
4141
{
4242
$form = $this->createForm('gender');
4343

44-
$this->assertEquals(['male' => 'Male', 'female' => 'Female'], $form->getConfig()->getOption('choices'));
44+
$this->assertEquals(['Male' => 'male', 'Female' => 'female'], $form->getConfig()->getOption('choices'));
4545
}
4646

4747
protected function getExtensions()

0 commit comments

Comments
 (0)