8000 [DX][Form] Defining validation groups on form field level should throw an error · Issue #12342 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[DX][Form] Defining validation groups on form field level should throw an error #12342
Closed
@umpirsky

Description

@umpirsky

Talk is cheap, show me the code:

class MyFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('foo', 'text', [
            'constraints'       => new Constraints\Length(['min' => 6]),
            'validation_groups' => 'Bar',
        ]);
    }
 }

I expected this code to be equivalent to:

class MyFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('foo', 'text', [
            'constraints'  => new Constraints\Length(['min' => 6, 'groups' => 'Bar']),
        ]);
    }
 }

But it is not, validation groups are not respected in the first case.

If it cannot be fixed before 3.0, then it can at least throw an error like:

You cannot define validation groups to a form field, consider passing it as an option to your constraints.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0