From 1a410e496c004de866de35367d785c6a80258b85 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Thu, 23 Oct 2014 11:26:28 +0200 Subject: [PATCH 1/2] Fixed sentence --- components/console/changing_default_command.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/console/changing_default_command.rst b/components/console/changing_default_command.rst index 1c191ba8571..757a0c9f88c 100644 --- a/components/console/changing_default_command.rst +++ b/components/console/changing_default_command.rst @@ -8,9 +8,9 @@ Changing the Default Command The :method:`Symfony\\Component\\Console\\Application::setDefaultCommand` method was introduced in Symfony 2.5. -will always run the ``ListCommand`` when no command name is passed. In order to change -the default command you just need to pass the command name you want to run by -default to the ``setDefaultCommand`` method:: +The Console component will always run the ``ListCommand`` when no command name is +passed. In order to change the default command you just need to pass the command +name to the ``setDefaultCommand`` method:: namespace Acme\Console\Command; From 5deccd2682f71562a2ff16fa59de149a20e3af1e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 23 Aug 2014 10:28:59 +0200 Subject: [PATCH 2/2] describe how to access form errors --- components/form/introduction.rst | 27 +++++++++++++++++++++++++++ reference/forms/types/form.rst | 2 ++ 2 files changed, 29 insertions(+) diff --git a/components/form/introduction.rst b/components/form/introduction.rst index 74b47461b65..7b0dcd371d1 100644 --- a/components/form/introduction.rst +++ b/components/form/introduction.rst @@ -660,6 +660,33 @@ and the errors will display next to the fields on error. For a list of all of the built-in validation constraints, see :doc:`/reference/constraints`. +Accessing Form Errors +~~~~~~~~~~~~~~~~~~~~~ + +You can use the :method:`Symfony\\Component\\Form\\FormInterface::getErrors` +method to access the list of errors. Each element is a :class:`Symfony\\Component\\Form\\FormError` +object:: + + $form = ...; + + // ... + + // an array of FormError objects, but only errors attached to this form level (e.g. "global errors) + $errors = $form->getErrors(); + + // an array of FormError objects, but only errors attached to the "firstName" field + $errors = $form['firstName']->getErrors(); + + // a string representation of all errors of the whole form tree + $errors = $form->getErrorsAsString(); + +.. note:: + + If you enable the :ref:`error_bubbling ` + option on a field, calling ``getErrors()`` on the parent form will include + errors from that field. However, there is no way to determine which field + an error was originally attached to. + .. _Packagist: https://packagist.org/packages/symfony/form .. _Twig: http://twig.sensiolabs.org .. _`Twig Configuration`: http://twig.sensiolabs.org/doc/intro.html diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index 7bf4d09df76..8ea4a6ce437 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -78,6 +78,8 @@ The actual default value of this option depends on other field options: .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER +.. _reference-form-option-error-bubbling: + .. include:: /reference/forms/types/options/error_bubbling.rst.inc .. include:: /reference/forms/types/options/error_mapping.rst.inc