Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

ChoiceType returns wrong data on submit if clearMissing is false #16802

Copy link
Copy link
Closed
@ossinkine

Description

@ossinkine
Issue body actions

I've created TestFormType

class TestType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('text', 'text')
            ->add('choice', 'choice', ['choices' => ['FOO' => 'foo', 'BAR' => 'bar'], 'expanded' => true])
        ;
    }

    public function getName()
    {
        return 'test';
    }
}

created the form and trying to submit data

$data = [
    'text'   => 'foo',
    'choice' => 'foo',
];
$form = $this->createForm('test', $data);
$form->submit(
    [
        'text'   => 'bar',
        'choice' => 'bar',
    ],
    false
);

and now $form->getData() will return an array:

array (size=2)
    'text' => string 'bar' (length=3)
    'choice' => string 'foo' (length=3)

I expect to receive bar for both fields.

I'm working on the latest version of 4.4 branch
See the reproducer for this issue https://github.com/ossinkine/symfony-issue-16802

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.