Skip to content

[Form] [EventListener] fixed sending non array data on preSubmit to ResizeFormListener #13851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function preSubmit(FormEvent $event)
}

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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,14 @@ public function testPreSubmitDoesNothingIfNotAllowAddNorAllowDelete()
$this->assertFalse($this->form->has('2'));
}

/**
* @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException
*/
public function testPreSubmitRequiresArrayOrTraversable()
public function testPreSubmitDealsWithNoArrayOrTraversable()
{
$data = 'no array or traversable';
$event = new FormEvent($this->form, $data);
$listener = new ResizeFormListener('text', array(), false, false);
$listener->preSubmit($event);

$this->assertFalse($this->form->has('1'));
}

public function testPreSubmitDealsWithNullData()
Expand Down