Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 63c8ce9

Browse files
committed
bug #13851 [Form] [EventListener] fixed sending non array data on preSubmit to ResizeFormListener (BruceWouaigne)
This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #13851). Discussion ---------- [Form] [EventListener] fixed sending non array data on preSubmit to ResizeFormListener | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #13804 | License | MIT | Doc PR | - Commits ------- 74d794b [Form] [EventListener] fixed sending non array data on submit to ResizeListener
2 parents 04ae391 + 74d794b commit 63c8ce9

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)