File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed
src/Symfony/Component/Form Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ public function offsetUnset($offset)
106
106
*/
107
107
public function setParent (FormInterface $ parent = null )
108
108
{
109
+ if ($ this ->submitted ) {
110
+ throw new AlreadySubmittedException ('You cannot set the parent of a submitted button ' );
111
+ }
112
+
109
113
$ this ->parent = $ parent ;
110
114
}
111
115
Original file line number Diff line number Diff line change @@ -30,18 +30,34 @@ protected function setUp()
30
30
$ this ->factory = $ this ->getMockBuilder ('Symfony\Component\Form\FormFactoryInterface ' )->getMock ();
31
31
}
32
32
33
+ /**
34
+ * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException
35
+ */
36
+ public function testSetParentOnSubmittedButton ()
37
+ {
38
+ $ button = $ this ->getButtonBuilder ('button ' )
39
+ ->getForm ()
40
+ ;
41
+
42
+ $ button ->submit ('' );
43
+
44
+ $ button ->setParent ($ this ->getFormBuilder ('form ' )->getForm ());
45
+ }
46
+
33
47
/**
34
48
* @dataProvider getDisabledStates
35
49
*/
36
50
public function testDisabledIfParentIsDisabled ($ parentDisabled , $ buttonDisabled , $ result )
37
51
{
38
52
$ form = $ this ->getFormBuilder ('form ' )
39
53
->setDisabled ($ parentDisabled )
40
- ->getForm ();
54
+ ->getForm ()
55
+ ;
41
56
42
57
$ button = $ this ->getButtonBuilder ('button ' )
43
58
->setDisabled ($ buttonDisabled )
44
- ->getForm ();
59
+ ->getForm ()
60
+ ;
45
61
46
62
$ button ->setParent ($ form );
47
63
You can’t perform that action at this time.
0 commit comments