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 70d9ba9

Browse filesBrowse files
committed
do not accept array input when a form is not multiple
1 parent 2ec626f commit 70d9ba9
Copy full SHA for 70d9ba9

File tree

3 files changed

+8
-3
lines changed
Filter options

3 files changed

+8
-3
lines changed

‎src/Symfony/Component/Form/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Form.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ public function submit($submittedData, $clearMissing = true)
547547
$submittedData = null;
548548
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, file upload given.');
549549
}
550-
} elseif (\is_array($submittedData) && !$this->config->getCompound() && !$this->config->hasOption('multiple')) {
550+
} elseif (\is_array($submittedData) && !$this->config->getCompound() && !$this->config->getOption('multiple', false)) {
551551
$submittedData = null;
552552
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, array given.');
553553
}

‎src/Symfony/Component/Form/Tests/CompoundFormTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/CompoundFormTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1057,7 +1057,8 @@ public function testArrayTransformationFailureOnSubmit()
10571057
$this->assertNull($this->form->get('foo')->getData());
10581058
$this->assertSame('Submitted data was expected to be text or number, array given.', $this->form->get('foo')->getTransformationFailure()->getMessage());
10591059

1060-
$this->assertSame(['bar'], $this->form->get('bar')->getData());
1060+
$this->assertNull($this->form->get('bar')->getData());
1061+
$this->assertSame('Submitted data was expected to be text or number, array given.', $this->form->get('bar')->getTransformationFailure()->getMessage());
10611062
}
10621063

10631064
public function testFileUpload()

‎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
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1918,7 +1918,11 @@ public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionDa
19181918

19191919
$form->submit($submissionData);
19201920
$this->assertFalse($form->isSynchronized());
1921-
$this->assertEquals('All choices submitted must be NULL, strings or ints.', $form->getTransformationFailure()->getMessage());
1921+
if (!$multiple && !$expanded) {
1922+
$this->assertEquals('Submitted data was expected to be text or number, array given.', $form->getTransformationFailure()->getMessage());
1923+
} else {
1924+
$this->assertEquals('All choices submitted must be NULL, strings or ints.', $form->getTransformationFailure()->getMessage());
1925+
}
19221926
}
19231927

19241928
public function invalidNestedValueTestMatrix()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.