Skip to content

Commit 5ea2920

Browse files
Merge branch '2.8' into 3.3
* 2.8: [Form] Fixed ContextErrorException in FileType [DI] Fix handling of inlined definitions by ContainerBuilder
2 parents e260ab8 + 106a443 commit 5ea2920

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

Extension/Core/Type/FileType.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3434

3535
if ($options['multiple']) {
3636
$data = array();
37+
$files = $event->getData();
3738

38-
foreach ($event->getData() as $file) {
39+
if (!is_array($files)) {
40+
$files = array();
41+
}
42+
43+
foreach ($files as $file) {
3944
if ($requestHandler->isFileUpload($file)) {
4045
$data[] = $file;
4146
}

Tests/Extension/Core/Type/FileTypeTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,24 @@ public function testMultipleSubmittedFilePathsAreDropped(RequestHandlerInterface
159159
$this->assertCount(1, $form->getData());
160160
}
161161

162+
/**
163+
* @dataProvider requestHandlerProvider
164+
*/
165+
public function testSubmitNonArrayValueWhenMultiple(RequestHandlerInterface $requestHandler)
166+
{
167+
$form = $this->factory
168+
->createBuilder(static::TESTED_TYPE, null, array(
169+
'multiple' => true,
170+
))
171+
->setRequestHandler($requestHandler)
172+
->getForm();
173+
$form->submit(null);
174+
175+
$this->assertSame(array(), $form->getData());
176+
$this->assertSame(array(), $form->getNormData());
177+
$this->assertSame(array(), $form->getViewData());
178+
}
179+
162180
public function requestHandlerProvider()
163181
{
164182
return array(

0 commit comments

Comments
 (0)