[Form] Fixed: Form::bind() throws an exception if form is anonymous
This commit is contained in:
parent
6ff4120784
commit
bd3e6c6b49
@ -713,6 +713,10 @@ class Form extends Field implements \IteratorAggregate, FormInterface
|
||||
*/
|
||||
public function bind(Request $request, $data = null)
|
||||
{
|
||||
if (!$this->getName()) {
|
||||
throw new FormException('You cannot bind anonymous forms. Please give this form a name');
|
||||
}
|
||||
|
||||
// Store object from which to read the default values and where to
|
||||
// write the submitted values
|
||||
if (null !== $data) {
|
||||
|
@ -276,6 +276,16 @@ class FormTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array('group2'), $childForm->getValidationGroups());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException Symfony\Component\Form\Exception\FormException
|
||||
*/
|
||||
public function testBindThrowsExceptionIfAnonymous()
|
||||
{
|
||||
$form = new Form(null, array('validator' => $this->createMockValidator()));
|
||||
|
||||
$form->bind($this->createPostRequest());
|
||||
}
|
||||
|
||||
public function testBindValidatesData()
|
||||
{
|
||||
$form = new Form('author', array(
|
||||
|
Reference in New Issue
Block a user