Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[WIP] [2.7] [Form] fixempty_data option in expandedChoiceType#17822
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
HeahDude commentedFeb 18, 2016
This one misses its |
HeahDude commentedApr 9, 2016
@webmozart Can you have a look at this one please ? |
b4858c7 tod479adfCompareHeahDude commentedJun 25, 2016
@symfony/deciders this bug is still present and is very annoying, this PR allows to use Could you please review? |
fabpot commentedJun 28, 2016
Thank you@HeahDude. |
…oiceType` (HeahDude)This PR was merged into the 2.7 branch.Discussion----------[WIP] [2.7] [Form] fix `empty_data` option in expanded `ChoiceType`| Q | A| ------------- | ---| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#17791| License | MIT| Doc PR | -It might happen because in `Form::submit()` the handling of `empty_data` [line 597](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php#L597) comes after each child of a compound field has been submitted [line 549](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php#L549).So when `ChoiceType` is `expanded`, `compound` option is defaulted to `true` and it passes its empty submitted data to its children before handling its own `empty_data` option.This PR uses the listener already added in `ChoiceType` only when `expanded` is true to handle `empty_data` at `PRE_SUBMIT` [line 539](https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Form/Form.php#L539).- [ ] Fix FQCN in tests for 2.8- [ ] Remove `choices_as_values` in tests for 3.0Commits-------d479adf [Form] fix `empty_data` option in expanded `ChoiceType`
HeahDude commentedJun 28, 2016
Thank you@fabpot |
This PR was merged into the 3.0 branch.Discussion----------[Form] fixed ChoiceTypeTest after#17822| Q | A| ------------- | ---| Branch? | 3.0| Bug fix? | no| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets | ~| License | MIT| Doc PR | ~Commits-------777c193 [Form] fixed ChoiceTypeTest after#17822
* 3.0: [Form] fixed ChoiceTypeTest after#17822
…e (HeahDude)This PR was merged into the 2.7 branch.Discussion----------[Form] Fixed empty data on expanded ChoiceType and FileType| Q | A| ------------- | ---| Branch? | 2.7| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#25896| License | MIT| Doc PR | ~Alternative of#25924.I don't think we have to do this by adding overhead in master and getting it properly fixed in 2 years.This is bug I've introduced while fixing another bug#17822. Which then has been replicated in#20418 and#24993.I propose instead to clean up the code for all LTS, since this is a wrong behaviour that has never been documented, and most of all unreliable.The `empty_data` can by anything in the view format as long as the reverse view transformation supports it. Even an object derived from the data class could be invokable.I think we should remain consistent withhttps://github.com/symfony/symfony/blob/2.7/src/Symfony/Component/Form/Form.php#L615.Commits-------9722c06 [Form] Fixed empty data on expanded ChoiceType and FileType
It might happen because in
Form::submit()the handling ofempty_dataline 597 comes after each child of a compound field has been submittedline 549.So when
ChoiceTypeisexpanded,compoundoption is defaulted totrueand it passes its empty submitted data to its children before handling its ownempty_dataoption.This PR uses the listener already added in
ChoiceTypeonly whenexpandedis true to handleempty_dataatPRE_SUBMITline 539.choices_as_valuesin tests for 3.0