bug #15117 [Form] fixed sending non array data on submit to ResizeListener (BruceWouaigne)
This PR was merged into the 2.3 branch.
Discussion
----------
[Form] fixed sending non array data on submit to ResizeListener
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #13804, #13851
| License | MIT
| Doc PR |
I agree with @Tobion that #13851 is a bug fix and therefore should be applied on the `2.3` branch too.
Commits
-------
0f185c9
[Form] [EventListener] fixed sending non array data on submit to ResizeListener
This commit is contained in:
commit
3ef7a1f6d6
@ -101,7 +101,7 @@ class ResizeFormListener implements EventSubscriberInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
|
if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) {
|
||||||
throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)');
|
$data = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove all empty rows
|
// Remove all empty rows
|
||||||
|
@ -167,15 +167,14 @@ class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertFalse($this->form->has('2'));
|
$this->assertFalse($this->form->has('2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public function testPreSubmitDealsWithNoArrayOrTraversable()
|
||||||
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
|
|
||||||
*/
|
|
||||||
public function testPreSubmitRequiresArrayOrTraversable()
|
|
||||||
{
|
{
|
||||||
$data = 'no array or traversable';
|
$data = 'no array or traversable';
|
||||||
$event = new FormEvent($this->form, $data);
|
$event = new FormEvent($this->form, $data);
|
||||||
$listener = new ResizeFormListener('text', array(), false, false);
|
$listener = new ResizeFormListener('text', array(), false, false);
|
||||||
$listener->preSubmit($event);
|
$listener->preSubmit($event);
|
||||||
|
|
||||||
|
$this->assertFalse($this->form->has('1'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPreSubmitDealsWithNullData()
|
public function testPreSubmitDealsWithNullData()
|
||||||
|
Reference in New Issue
Block a user