Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions components/form.rst
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,21 @@ method to access the list of errors. It returns a
// a FormErrorIterator instance representing the form tree structure
$errors = $form->getErrors(true, false);

Clearing Form Errors
~~~~~~~~~~~~~~~~~~~~

.. versionadded:: 4.2
The ``clearErrors()`` method was introduced in Symfony 4.2.

Any errors can be manually cleared using the
:method:`Symfony\\Component\\Form\\ClearableErrorsInterface::clearErrors`
method. This is useful when you'd like to validate the form without showing
validation errors to the user (i.e. during a partial AJAX submission or
:doc:`dynamic form modification </form/dynamic_form_modification>`).

Because clearing the errors makes the form valid, ``clearErrors()`` should only
be called after testing whether the form is valid.

Learn more
----------

Expand Down