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 bd3e6c6

Browse filesBrowse files
Bernhard Schussekfabpot
Bernhard Schussek
authored andcommitted
[Form] Fixed: Form::bind() throws an exception if form is anonymous
1 parent 6ff4120 commit bd3e6c6
Copy full SHA for bd3e6c6

File tree

Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+14
-0
lines changed

‎src/Symfony/Component/Form/Form.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Form.php
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,10 @@ public function getCsrfProvider()
713713
*/
714714
public function bind(Request $request, $data = null)
715715
{
716+
if (!$this->getName()) {
717+
throw new FormException('You cannot bind anonymous forms. Please give this form a name');
718+
}
719+
716720
// Store object from which to read the default values and where to
717721
// write the submitted values
718722
if (null !== $data) {

‎tests/Symfony/Tests/Component/Form/FormTest.php

Copy file name to clipboardExpand all lines: tests/Symfony/Tests/Component/Form/FormTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ public function testValidationGroupsAreNotInheritedFromParentIfSet()
276276
$this->assertEquals(array('group2'), $childForm->getValidationGroups());
277277
}
278278

279+
/**
280+
* @expectedException Symfony\Component\Form\Exception\FormException
281+
*/
282+
public function testBindThrowsExceptionIfAnonymous()
283+
{
284+
$form = new Form(null, array('validator' => $this->createMockValidator()));
285+
286+
$form->bind($this->createPostRequest());
287+
}
288+
279289
public function testBindValidatesData()
280290
{
281291
$form = new Form('author', array(

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.