Skip to content

Commit a1153c2

Browse files
BruceWouaignexabbuh
authored andcommitted
[Form] [EventListener] fixed sending non array data on submit to ResizeListener
1 parent 76cd7e1 commit a1153c2

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Extension/Core/EventListener/ResizeFormListener.php

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

103103
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
104-
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
104+
$data = array();
105105
}
106106

107107
// Remove all empty rows

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)