You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
bug #15682 [Form] Added exception when setAutoInitialize() is called when locked (jaytaph)
This PR was submitted for the 2.7 branch but it was merged into the 2.3 branch instead (closes#15682).
Discussion
----------
[Form] Added exception when setAutoInitialize() is called when locked
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
It seems that this method was missing a "locked" check, since it changes state and a locked instance should be immutable. However, because `setAutoInitialize()` is useful during the building of a form, it doesn't really matter a lot whether or not it is changed. But for consistency, it would be nicer if this method too was checked.
Commits
-------
c269d6f Added exception when setAutoInitialize is called when locked
Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/FormConfigBuilder.php
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -855,6 +855,10 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler)
855
855
*/
856
856
publicfunctionsetAutoInitialize($initialize)
857
857
{
858
+
if ($this->locked) {
859
+
thrownewBadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
0 commit comments