Permalink
Browse files

feature #4246 [Reference] add description for the `validation_groups`…

… 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 62bafad2a1cb6718bde3ae7d7612e65bfd3fd123
Showing with 30 additions and 0 deletions.
  1. +2 −0 book/forms.rst
  2. +28 −0 reference/forms/types/submit.rst
@@ -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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -17,6 +17,7 @@ A submit button.
| | - `label`_ |
| | - `label_attr`_ |
| | - `translation_domain`_ |
| | - `validation_groups`_ |
+----------------------+----------------------------------------------------------------------+
| Parent type | :doc:`button</reference/forms/types/button>` |
+----------------------+----------------------------------------------------------------------+
@@ -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
--------------

0 comments on commit 62bafad

Please sign in to comment.