Skip to content

Commit a5d15d2

Browse files
committed
feature #8522 Add GroupSequence validation_groups capability doc (damienalexandre, javiereguiluz)
This PR was merged into the 2.7 branch. Discussion ---------- Add GroupSequence validation_groups capability doc When using form types without object, we often define constraints in the form itself. I missed a way to use the sequential groups without object, but already implemented, so here is the documentation for it 😋 Cheers. Commits ------- 9eb4b11 Minor syntax issues 39f9143 Fix code-block 6ad18f2 Add GroupSequence validation_groups capability doc
2 parents a6f299e + 9eb4b11 commit a5d15d2

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

validation/sequence_provider.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,23 @@ that group are valid, the second group, ``Strict``, will be validated.
140140
sequence, which will contain the ``Default`` group which references the
141141
same group sequence, ...).
142142

143+
You can also define a group sequence in the ``validation_groups`` form option::
144+
145+
use Symfony\Component\Validator\Constraints\GroupSequence;
146+
use Symfony\Component\Form\AbstractType;
147+
// ...
148+
149+
class MyType extends AbstractType
150+
{
151+
// ...
152+
public function configureOptions(OptionsResolver $resolver)
153+
{
154+
$resolver->setDefaults([
155+
'validation_groups' => new GroupSequence(['First', 'Second']),
156+
]);
157+
}
158+
}
159+
143160
Group Sequence Providers
144161
------------------------
145162

0 commit comments

Comments
 (0)