8000 bug #15682 [Form] Added exception when setAutoInitialize() is called … · symfony/symfony@ddf79da · GitHub
[go: up one dir, main page]

Skip to content

Commit ddf79da

Browse files
committed
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
2 parents 16ba457 + c269d6f commit ddf79da

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Symfony/Component/Form/FormConfigBuilder.php

Lines changed: 4 additions & 7CBD 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,10 @@ public function setRequestHandler(RequestHandlerInterface $requestHandler)
855855
*/
856856
public function setAutoInitialize($initialize)
857857
{
858+
if ($this->locked) {
859+
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
860+
}
861+
858862
$this->autoInitialize = (bool) $initialize;
859863

860864
return $this;

0 commit comments

Comments
 (0)
0