File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -660,6 +660,27 @@ and the errors will display next to the fields on error.
660
660
For a list of all of the built-in validation constraints, see
661
661
:doc: `/reference/constraints `.
662
662
663
+ Accessing Form Errors
664
+ ~~~~~~~~~~~~~~~~~~~~~
665
+
666
+ You can use the :method: `Symfony\\ Component\\ Form\\ FormInterface::getErrors `
667
+ method to access the list of errors. Each element is a :class: `Symfony\\ Component\\ Form\\ FormError `
668
+ object::
669
+
670
+ $form = ...;
671
+
672
+ // ...
673
+
674
+ // array of FormError objects
675
+ $errors = $form->getErrors();
676
+
677
+ .. note ::
678
+
679
+ Unless you enable the :ref: `error_bubbling <reference-form-option-error-bubbling >`
680
+ option on a particular child form, ``getErrors() `` only returns the errors
681
+ of the form it is accessed on. For debugging purposes, you can use the :method: `Symfony\\ Component\\ Form\\ Form::getErrorsAsString ` method which
682
+ returns a string representation of all errors of the whole form tree.
683
+
663
684
.. _Packagist : https://packagist.org/packages/symfony/form
664
685
.. _Twig : http://twig.sensiolabs.org
665
686
.. _`Twig Configuration` : http://twig.sensiolabs.org/doc/intro.html
Original file line number Diff line number Diff line change @@ -78,6 +78,8 @@ The actual default value of this option depends on other field options:
78
78
.. include :: /reference/forms/types/options/empty_data.rst.inc
79
79
:start-after: DEFAULT_PLACEHOLDER
80
80
81
+ .. _reference-form-option-error-bubbling :
82
+
81
83
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
82
84
83
85
.. include :: /reference/forms/types/options/error_mapping.rst.inc
You can’t perform that action at this time.
0 commit comments