Skip to content

Instantly share code, notes, and snippets.

@xphere
Created November 19, 2015 13:10
Show Gist options
  • Select an option

  • Save xphere/cb2005111e75f4ba013e to your computer and use it in GitHub Desktop.

Select an option

Save xphere/cb2005111e75f4ba013e to your computer and use it in GitHub Desktop.
Am I using GroupSequence correctly? Constraints aren't called when validating this form.
<?php
class MyFormType extends AbstractType
{
public funcion buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('username', 'text', [
'required' => true,
'validation_groups' => new GroupSequence(['Default', 'Strict']),
'constraints' => [
new NotBlank(),
new Length(['min' => 3]),
new Regex(['pattern' => '/^[a-zA-Z][a-zA-Z0-9_-]+$/']),
new NotForbiddenUsername([
'groups' => ['Strict'],
]),
new NotExistUsername([
'groups' => ['Strict'],
]),
],
]);
}
}
@HayekClub
Copy link
Copy Markdown

I ran into this issue today with Symfony 2.7.6. Glad that the workaround does work for me. Was the issue already solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment