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

[Form] Choice type int values (BC Fix) #21957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions 4 src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
}

foreach ($data as $v) {
if (null !== $v && !is_string($v)) {
throw new TransformationFailedException('All choices submitted must be NULL or strings.');
if (null !== $v && !is_string($v) && !is_int($v)) {
throw new TransformationFailedException('All choices submitted must be NULL, strings or ints.');
}
}
}, 256);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,19 @@ public function testSubmitMultipleExpandedNumericChoices()
$this->assertNull($form[4]->getViewData());
}

public function testSubmitMultipleChoicesInts()
{
$form = $this->factory->create(static::TESTED_TYPE, null, array(
'multiple' => true,
'choices' => array_flip($this->numericChoicesFlipped),
'choices_as_values' => true,
));

$form->submit(array(1, 2));

$this->assertTrue($form->isSynchronized());
}

public function testSingleSelectedObjectChoices()
{
$view = $this->factory->create(static::TESTED_TYPE, $this->objectChoices[3], array(
Expand Down Expand Up @@ -2306,7 +2319,7 @@ public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionDa

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

public function invalidNestedValueTestMatrix()
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.