-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Deprecated setting "choices_as_values" to "false" #16681
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
Conversation
1176ba1
to
d13a042
Compare
@@ -110,7 +110,7 @@ Form | |||
|
|||
* You should flip the keys and values of the "choices" option in ChoiceType | |||
and set the "choices_as_values" option to `true`. The default value of that | |||
option will be switched to `true` in Symfony 3.0. | |||
option will be switched to `true` in Symfony 2.8. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changing this in 2.8 would be a bc break isn't it? it has to be in 3.0
d13a042
to
c7b1ce7
Compare
e94870e
to
76f4e6c
Compare
👍 |
*/ | ||
private static function getFlippedTimezones() | ||
{ | ||
if (null === static::$timezones) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this must use self::
to access private properties, not static::
. Otherwise the code is broken when extending the class (as it would try to access the property on the child class, where it is not there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
76f4e6c
to
4a040f9
Compare
IMO, this needs to be done in 2.8, not in 2.7. Existing 2.7 projects running without deprecation warnings should not get such new warning in the next patch release. |
@stof only the deprecation triggering part then. The code should really remain here. |
This is not possible, as it would mean that it is impossible to write code working on 2.8 and 3.0 without deprecation notices. |
@stof The option was already deprecated (check the UPGRADE file), but the deprecation error was missing. The upgrade path is: 2.7: choices_as_values=false is deprecated, you should set it to true We can also switch the first step to 2.8 if you prefer that. |
@webmozart in case we forgot deprecation warnings in 2.7 before the release, they have been added in 2.8 in the past. So the deprecation warning should go in 2.8 |
4a040f9
to
721d09f
Compare
@stof Ok. I changed the deprecation message to 2.8. Let's merge this into 2.8. |
Thank you @webmozart. |
…webmozart) This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #16681). Discussion ---------- [Form] Deprecated setting "choices_as_values" to "false" | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #14951 | License | MIT | Doc PR | - This PR does two important things that were forgot in the 2.7 branch: * The value `false` of the `choices_as_values` option was deprecated, but the deprecation error was missing. This error was added now. The option should be set to `true`, the entries of the corresponding `choices` option should be flipped. In 2.8, the `choices_as_values` option will be deprecated entirely. * When setting `choices_as_values` to `true`, the generated HTML values of choices always fell back to `0`, `1`, …, even when the choices can be converted to duplicate-free strings. This is fixed now: The HTML values now equal the string cast of the choices whenever possible to match the <2.7 behavior. Commits ------- 5d7678e [Form] Deprecated setting "choices_as_values" to "false"
…art) This PR was merged into the 2.8 branch. Discussion ---------- [Form] Deprecated TimezoneType::getTimezones() | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This method is useless as of #16681. It needs to be deprecated before we can remove it since it is public. Commits ------- 41df3fc [Form] Deprecated TimezoneType::getTimezones()
…art) This PR was merged into the 2.8 branch. Discussion ---------- [Form] Deprecated TimezoneType::getTimezones() | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This method is useless as of symfony/symfony#16681. It needs to be deprecated before we can remove it since it is public. Commits ------- 41df3fc [Form] Deprecated TimezoneType::getTimezones()
…webmozart) This PR was merged into the 2.7 branch. Discussion ---------- [Form] Deprecated setting "choices_as_values" to "false" | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This is #16681 for 2.7, i.e. without the deprecations trigger Commits ------- 3ab8189 [Form] Deprecated setting "choices_as_values" to "false"
…art) This PR was merged into the 2.8 branch. Discussion ---------- [Form] Deprecated TimezoneType::getTimezones() | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - This method is useless as of symfony/symfony#16681. It needs to be deprecated before we can remove it since it is public. Commits ------- 41df3fc [Form] Deprecated TimezoneType::getTimezones()
@webmozart If I am looking at your upgrade path wouldn't it make sense to set |
@peterrehm see #16715. The option exists in 3.0, but is ignored, and the behavior acts as if it's set to true. So you'll set |
This PR was merged into the 2.8 branch. Discussion ---------- Upgrade information for the choice_value option | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Relates to #14825 and #14377. The behaviour was changed with #16681 so a not in the upgrade information makes sense to me. Commits ------- 28675c9 Reflected the change of the choice_value option in the Upgrade information
This PR does two important things that were forgot in the 2.7 branch:
false
of thechoices_as_values
option was deprecated, but the deprecation error was missing. This error was added now. The option should be set totrue
, the entries of the correspondingchoices
option should be flipped. In 2.8, thechoices_as_values
option will be deprecated entirely.choices_as_values
totrue
, the generated HTML values of choices always fell back to0
,1
, …, even when the choices can be converted to duplicate-free strings. This is fixed now: The HTML values now equal the string cast of the choices whenever possible to match the <2.7 behavior.