8000 minor #9916 [Form] Ability to clear form errors (colinodell, javiereg… · symfony/symfony-docs@53b6a51 · GitHub
[go: up one dir, main page]

Skip to content

Commit 53b6a51

Browse files
committed
minor #9916 [Form] Ability to clear form errors (colinodell, javiereguiluz)
This PR was merged into the master branch. Discussion ---------- [Form] Ability to clear form errors Documenting the new feature proposed in symfony/symfony#27580 Commits ------- f07f536 Wrap long lines and add the versionadded directive 7a4465d Clarify that clearing errors makes the form valid d4143f1 [Form] Ability to clear form errors
2 parents afeeec6 + f07f536 commit 53b6a51

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

components/form.rst

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,21 @@ method to access the list of errors. It returns a
744744
// a FormErrorIterator instance representing the form tree structure
745745
$errors = $form->getErrors(true, false);
746746

747+
Clearing Form Errors
748+
~~~~~~~~~~~~~~~~~~~~
749+
750+
.. versionadded:: 4.2
751+
The ``clearErrors()`` method was introduced in Symfony 4.2.
752+
753+
Any errors can be manually cleared using the
754+
:method:`Symfony\\Component\\Form\\ClearableErrorsInterface::clearErrors`
755+
method. This is useful when you'd like to validate the form without showing
756+
validation errors to the user (i.e. during a partial AJAX submission or
757+
:doc:`dynamic form modification </form/dynamic_form_modification>`).
758+
759+
Because clearing the errors makes the form valid, ``clearErrors()`` should only
760+
be called after testing whether the form is valid.
761+
747762
Learn more
748763
----------
749764

0 commit comments

Comments
 (0)
0