Skip to content

[Reference] add description for the validation_groups option #4246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 3, 2014
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions book/forms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ fields were submitted. If you want to suppress validation, you can use the
.. index::
single: Forms; Validation groups based on submitted data

.. _book-form-validation-groups:

Groups based on the Submitted Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
28 changes: 28 additions & 0 deletions reference/forms/types/submit.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ A submit button.
| | - `label`_ |
| | - `label_attr`_ |
| | - `translation_domain`_ |
| | - `validation_groups`_ |
+----------------------+----------------------------------------------------------------------+
| Parent type | :doc:`button</reference/forms/types/button>` |
+----------------------+----------------------------------------------------------------------+
Expand Down Expand Up @@ -45,6 +46,33 @@ Inherited Options

.. include:: /reference/forms/types/options/button_translation_domain.rst.inc

validation_groups
~~~~~~~~~~~~~~~~~

**type**: ``array`` **default**: ``null``

When your form contains multiple submit buttons, you can change the validation
group based on the button which was used to submit the form. Imagine a registration
form wizard with buttons to go to the previous or the next step::

$form = $this->createFormBuilder($user)
->add('previousStep', 'submit', array(
'validation_groups' => false,
))
->add('nextStep', 'submit', array(
'validation_groups' => array('Registration'),
))
->getForm();

The special ``false`` ensures that no validation is performed when the previous
step button is clicked. When the second button is clicked, all constraints
from the "Registration" are validated.

.. seealso::

You can read more about this in :ref:`the Form chapter <book-form-validation-groups>`
of the book.

Form Variables
--------------

Expand Down