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 74d794b

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

File tree

Expand file treeCollapse file tree

2 files changed

+4
-5
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+4
-5
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php
+1-1Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php
+3-4Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.