Skip to content

Commit

Permalink
feature #4246 [Reference] add description for the validation_groups
Browse files Browse the repository at this point in the history
… option (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Reference] add description for the `validation_groups` option

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes (symfony/symfony#6528)
| Applies to    | all
| Fixed tickets | #3358

Commits
-------

c41b17c add description for the `validation_groups` option
  • Loading branch information
weaverryan committed Oct 3, 2014
2 parents 9591a04 + c41b17c commit 62bafad
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
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

0 comments on commit 62bafad

Please sign in to comment.