Skip to content

Commit 106a443

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

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
@@ -169,6 +169,24 @@ public function testMultipleSubmittedFilePathsAreDropped(RequestHandlerInterface
169169
$this->assertCount(1, $form->getData());
170170
}
171171

172+
/**
173+
* @dataProvider requestHandlerProvider
174+
*/
175+
public function testSubmitNonArrayValueWhenMultiple(RequestHandlerInterface $requestHandler)
176+
{
177+
$form = $this->factory
178+
->createBuilder(static::TESTED_TYPE, null, array(
179+
'multiple' => true,
180+
))
181+
->setRequestHandler($requestHandler)
182+
->getForm();
183+
$form->submit(null);
184+
185+
$this->assertSame(array(), $form->getData());
186+
$this->assertSame(array(), $form->getNormData());
187+
$this->assertSame(array(), $form->getViewData());
188+
}
189+
172190
public function requestHandlerProvider()
173191
{
174192
return array(

0 commit comments

Comments
 (0)