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 @@ -617,6 +617,27 @@ and the errors will display next to the fields on error.
617
617
For a list of all of the built-in validation constraints, see
618
618
:doc: `/reference/constraints `.
619
619
620
+ Accessing Form Errors
621
+ ~~~~~~~~~~~~~~~~~~~~~
622
+
623
+ You can use the :method: `Symfony\\ Component\\ Form\\ FormInterface::getErrors `
624
+ method to access the list of errors. Each element is a :class: `Symfony\\ Component\\ Form\\ FormError `
625
+ object::
626
+
627
+ $form = ...;
628
+
629
+ // ...
630
+
631
+ // array of FormError objects
632
+ $errors = $form->getErrors();
633
+
634
+ .. note ::
635
+
636
+ Unless you enable the :ref: `error_bubbling <reference-form-option-error-bubbling >`
637
+ option on a particular child form, ``getErrors() `` only returns the errors
638
+ of the form it is accessed on. For debugging purposes, you can use the :method: `Symfony\\ Component\\ Form\\ Form::getErrorsAsString ` method which
639
+ returns a string representation of all errors of the whole form tree.
640
+
620
641
.. _Packagist : https://packagist.org/packages/symfony/form
621
642
.. _Twig : http://twig.sensiolabs.org
622
643
.. _`Twig Configuration` : http://twig.sensiolabs.org/doc/intro.html
Original file line number Diff line number Diff line change @@ -76,6 +76,8 @@ The actual default value of this option depends on other field options:
76
76
.. include :: /reference/forms/types/options/empty_data.rst.inc
77
77
:start-after: DEFAULT_PLACEHOLDER
78
78
79
+ .. _reference-form-option-error-bubbling :
80
+
79
81
.. include :: /reference/forms/types/options/error_bubbling.rst.inc
80
82
81
83
.. include :: /reference/forms/types/options/error_mapping.rst.inc
You can’t perform that action at this time.
0 commit comments