Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit dad87f8

Browse filesBrowse files
committed
Allow integer values in ChoiceType
1 parent 6d42909 commit dad87f8
Copy full SHA for dad87f8

File tree

2 files changed

+3
-3
lines changed
Filter options

2 files changed

+3
-3
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+2-2Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php
+1-1Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.