Skip to content

Commit 23ff699

Browse files
committed
minor #1443 Fix comment stating isSubmitted is optional (smnandre)
This PR was merged into the main branch. Discussion ---------- Fix comment stating isSubmitted is optional The isSubmitted() _must_ be called before [src/Symfony/Component/Form/Form.php](https://github.com/symfony/symfony/blob/6637b78a4fcba7cef818f2a022e096d503690ac5/src/Symfony/Component/Form/Form.php#L646-L657) ```php public function isValid(): bool { if (!$this->submitted) { throw new LogicException('Cannot check if an unsubmitted form is valid. Call Form::isSubmitted() and ensure that it\'s true before calling Form::isValid().'); } if ($this->isDisabled()) { return true; } return 0 === \count($this->getErrors(true)); } ``` Commits ------- 6da03aa Fix comment stating isSubmitted is optional
2 parents 578246c + 6da03aa commit 23ff699

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/Controller/Admin/BlogController.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,8 @@ public function new(
8686

8787
$form->handleRequest($request);
8888

89-
// the isSubmitted() method is completely optional because the other
90-
// isValid() method already checks whether the form is submitted.
91-
// However, we explicitly add it to improve code readability.
89+
// The isSubmitted() call is mandatory because the isValid() method
90+
// throws an exception if the form has not been submitted.
9291
// See https://symfony.com/doc/current/forms.html#processing-forms
9392
if ($form->isSubmitted() && $form->isValid()) {
9493
$entityManager->persist($post);

0 commit comments

Comments
 (0)