Skip to content

[FORM] invalid ExecutionContext #37185

Closed
Closed
@versh23

Description

@versh23

Symfony version(s) affected: 5.0.9\5.1.0

Description

After this PR #36865 we have a BUG
there are invalid ExecutionContext.getObject when using subforms

Example

class LoginType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $callback = function ($object, ExecutionContextInterface $context, $payload) {
            dump($context->getObject()->getName(), $context->getRoot()->getName());
        };

        $builder
            ->add('username', TextType::class, [
                'constraints' => new NotBlank(),
            ])
            ->add('form2', LoginType2::class, [
                'constraints' => [
                    new Callback($callback)
                ]
            ]);
        ;
    }
}

dump

LoginType.php on line 19:
"login"
LoginType.php on line 19:
"login"

If revert changed
dump

LoginType.php on line 19:
"form2"
LoginType.php on line 19:
"login"

@xabbuh

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