Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Form] RepeatedType should always have inner types mapped #36411

Merged
merged 1 commit into from Apr 13, 2020

Conversation

biozshock
Copy link
Contributor

@biozshock biozshock commented Apr 10, 2020

Q A
Branch? 3.4
Bug fix? yes
New feature? no
Deprecations? no
Doc PR symfony/symfony-docs#13519
Tickets Fix #36410
License MIT

Always set mapped=true to override inner type mapped setting.
Throw an exception if inner types of RepeatedType has mapped=false

@biozshock biozshock requested a review from xabbuh as a code owner April 10, 2020 11:46
@biozshock biozshock force-pushed the repeated-type_not-mapped branch 2 times, most recently from 479d0f6 to 7cfe1fe Compare April 10, 2020 11:55
Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I was about to suggest you to create PR to do so, thanks!

It adds complexity to validate the option, but we can easily enforce the expected behavior so I'm 👍 for targeting 3.4 with this fix.

* @param string $configurationKey
* @dataProvider notMappedConfigurationKeys
*/
public function testNotMappedInner($configurationKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this could be removed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or better, adapted to have the same behavior as the other.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@biozshock biozshock force-pushed the repeated-type_not-mapped branch 2 times, most recently from 9af2203 to 2c80cb8 Compare April 10, 2020 16:41
Copy link
Contributor

@HeahDude HeahDude left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! (minor comment)

$builder
->addViewTransformer(new ValueToDuplicatesTransformer([
$options['first_name'],
$options['second_name'],
]))
->add($options['first_name'], $options['type'], array_merge($options['options'], $options['first_options']))
->add($options['second_name'], $options['type'], array_merge($options['options'], $options['second_options']))
->add(
Copy link
Contributor

@HeahDude HeahDude Apr 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep it on one line to follow our standards, this also reduces the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought fabbot will complain about 120 symbols line.

@biozshock
Copy link
Contributor Author

Added doc PR.

@nicolas-grekas nicolas-grekas added this to the 3.4 milestone Apr 10, 2020
}

/**
* @param string $configurationKey
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Just a side question in case you have time: Wouldn't such comments ease moving to typehinted scalar types when 3.4 will be EOL and 4.4 will require 7.1?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are not covered by BC promise, we do add those in the code base though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already added all possible types in 5.0, we should not forget to add it here also that's true; but if we do, that's no big deal (and eventually someone will figure out :) )

@xabbuh
Copy link
Member

xabbuh commented Apr 11, 2020

Wouldn't it make sense to check if we could make the type work with the mapped option set to false?

@HeahDude
Copy link
Contributor

You mean ignoring the option or config setting? It could if we target master with a new feature as the mapping is a requirement for the transformer to do the proper validation. I think that trying to do otherwise will lead to adding unnecessary complexity. Unless you see a simple way to do it?

@xabbuh
Copy link
Member

xabbuh commented Apr 11, 2020

What about something like #36430?

@nicolas-grekas nicolas-grekas changed the title RepeatedType should always have inner types mapped [Form] RepeatedType should always have inner types mapped Apr 13, 2020
@nicolas-grekas
Copy link
Member

Thank you @biozshock.

@nicolas-grekas nicolas-grekas merged commit f702863 into symfony:3.4 Apr 13, 2020
This was referenced Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants