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

[Form] RepeatedType with not mapped fields allows to have different values #36410

Copy link
Copy link
Closed
@biozshock

Description

@biozshock
Issue body actions

Symfony version(s) affected: 3.4

Description
If one (or both) fields in RepeatedType is not mapped the form allows to have different values

How to reproduce
Add to Tests/Extension/Core/Type/RepeatedTypeTest.php

public function testSubmitUnequalNotMapped(): void
{
    $input = ['first' => 'foo', 'second' => 'bar'];

    $form = $this->factory->create(static::TESTED_TYPE, null, [
        'type' => TextTypeTest::TESTED_TYPE,
        'first_options' => ['mapped' => false],
        'second_options' => ['mapped' => false],
    ]);

    $form->submit($input);

    $this->assertSame('foo', $form['first']->getViewData());
    $this->assertSame('bar', $form['second']->getViewData());
    $this->assertFalse($form->isSynchronized());
    $this->assertSame($input, $form->getViewData());
    $this->assertNull($form->getData());
}

Happens because \Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer is called with value === null on unmapped field.

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.