8000 Allow integer values in ChoiceType · symfony/symfony@dad87f8 · GitHub
[go: up one dir, main page]

Skip to content

Commit dad87f8

Browse files
committed
Allow integer values in ChoiceType
1 parent 6d42909 commit dad87f8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
171171
}
172172

173173
foreach ($data as $v) {
174-
if (null !== $v && !is_string($v)) {
175-
throw new TransformationFailedException('All choices submitted must be NULL or strings.');
174+
if (null !== $v && !is_string($v) && !is_int($v)) {
175+
throw new TransformationFailedException('All choices submitted must be NULL, strings or ints.');
176176
}
177177
}
178178
}, 256);

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2319,7 +2319,7 @@ public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionDa
23192319

23202320
$form->submit($submissionData);
23212321
$this->assertFalse($form->isSynchronized());
2322-
$this->assertEquals('All choices submitted must be NULL or strings.', $form->getTransformationFailure()->getMessage());
2322+
$this->assertEquals('All choices submitted must be NULL, strings or ints.', $form->getTransformationFailure()->getMessage());
23232323
}
23242324

23252325
public function invalidNestedValueTestMatrix()

0 commit comments

Comments
 (0)
0