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 6bffdbc

Browse filesBrowse files
committed
do not accept array input when a form is not multiple
1 parent f3df3d0 commit 6bffdbc
Copy full SHA for 6bffdbc

File tree

3 files changed

+10
-3
lines changed
Filter options

3 files changed

+10
-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
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
1515
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
1616
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
17+
use Symfony\Component\Form\Exception\TransformationFailedException;
1718
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
1819
use Symfony\Component\Form\FormInterface;
1920
use Symfony\Component\Form\Forms;
@@ -1918,7 +1919,12 @@ public function testSubmitInvalidNestedValue($multiple, $expanded, $submissionDa
19181919

19191920
$form->submit($submissionData);
19201921
$this->assertFalse($form->isSynchronized());
1921-
$this->assertEquals('All choices submitted must be NULL, strings or ints.', $form->getTransformationFailure()->getMessage());
1922+
$this->assertInstanceOf(TransformationFailedException::class, $form->getTransformationFailure());
1923+
if (!$multiple && !$expanded) {
1924+
$this->assertEquals('Submitted data was expected to be text or number, array given.', $form->getTransformationFailure()->getMessage());
1925+
} else {
1926+
$this->assertEquals('All choices submitted must be NULL, strings or ints.', $form->getTransformationFailure()->getMessage());
1927+
}
19221928
}
19231929

19241930
public function invalidNestedValueTestMatrix()

0 commit comments

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