8000 [Form] [EventListener] fixed sending non array data on submit to Resi… · symfony/symfony@74d794b · GitHub
[go: up one dir, main page]

Skip to content

Commit 74d794b

Browse files
BruceWouaignewebmozart
authored andcommitted
[Form] [EventListener] fixed sending non array data on submit to ResizeListener
1 parent 04ae391 commit 74d794b

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function preSubmit(FormEvent $event)
107107
}
108108

109109
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
110-
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
110+
$data = array();
111111
}
112112

113113
// Remove all empty rows

src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,14 @@ public function testPreSubmitDoesNothingIfNotAllowAddNorAllowDelete()
167167
$this->assertFalse($this->form->has('2'));
168168
}
169169

170-
/**
171-
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
172-
*/
173-
public function testPreSubmitRequiresArrayOrTraversable()
170+
public function testPreSubmitDealsWithNoArrayOrTraversable()
174171
{
175172
$data = 'no array or traversable';
176173
$event = new FormEvent($this->form, $data);
177174
$listener = new ResizeFormListener('text', array(), false, false);
178175
$listener->preSubmit($event);
176+
177+
$this->assertFalse($this->form->has('1'));
179178
}
180179

181180
public function testPreSubmitDealsWithNullData()

0 commit comments

Comments
 (0)
0