diff --git a/components/form.rst b/components/form.rst index e3b8a96689f..a4daedb3147 100644 --- a/components/form.rst +++ b/components/form.rst @@ -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 `). + +Because clearing the errors makes the form valid, ``clearErrors()`` should only +be called after testing whether the form is valid. + Learn more ----------