-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Form] Fixed empty data for compound date types #29182
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] Fixed empty data for compound date types #29182
Conversation
HeahDude
commented
Nov 11, 2018
Q | A |
---|---|
Branch? | 2.8 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | #4715 |
License | MIT |
Doc PR | ~ |
90a0ab0
to
d53e21a
Compare
d53e21a
to
9bab1e8
Compare
To give more context, https://github.com/symfony/symfony/pull/29179/files#diff-1c1084613d7579bc9e39092ac95364f9R1020 is the test revealing the inconsistency prior to fix compound cases in this PR. |
Thank you @HeahDude. |
This PR was merged into the 2.8 branch. Discussion ---------- [Form] Fixed empty data for compound date types | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #4715 | License | MIT | Doc PR | ~ Commits ------- 9bab1e8 [Form] Fixed empty data for compound date types
This PR was merged into the 3.4 branch. Discussion ---------- [Form] Fixed empty data for compound date interval | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #4715 (continuation) | License | MIT | Doc PR | ~ Following #29182, since this type has been introduced in Symfony 3 but with the same limitation explained in #4715. So for consistency this needs to be fixed here as well. Commits ------- 38a2abc [Form] Fixed empty data for compound date interval
@@ -226,6 +237,9 @@ public function configureOptions(OptionsResolver $resolver) | |||
// this option. | |||
'data_class' => null, | |||
'compound' => $compound, | |||
'empty_data' => function (Options $options) { | |||
return $options['compound'] ? array() : ''; |
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.
Hi @nicolas-grekas ,
Could you explain, why empty data is empty string instead of null as it was before?
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.
We are using DateTimeToRfc3339Transformer, and it's expecting null as an empty value, otherwise throws an exception, and probably the same issue will be with DateTimeToLocalizedStringTransformer
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.
empty_data
is in the view format. This value should not be passed to transform()
but to reverseTransform()
. Can you please open a new issue with fine steps that allow to reproduce if you think you found a bug?
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.
Hm, based on examples from the documentation and according to the code I thought empty_data
is a model format, not view, as it could be new $data_class()
.
Need to investigate then.
Thank you for the fast response!
…/Time form types (yceruto) This PR was merged into the 3.4 branch. Discussion ---------- [Form] Fix handling of empty_data's \Closure value in Date/Time form types | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #33188 | License | MIT | Doc PR | - Basically this would solve the posibility to pass a `\Closure` to the `empty_data` option for Date/Time form types. > https://symfony.com/doc/current/reference/forms/types/form.html#empty-data > If a form is compound, you can set empty_data as an array, object or **closure**. See the [How to Configure empty Data](https://symfony.com/doc/current/form/use_empty_data.html) for a Form Class article for more details about these options. Also related to #29182 Commits ------- 4939f0e Fix handling of empty_data's \Closure value in Date/Time form types
…/Time form types (yceruto) This PR was merged into the 3.4 branch. Discussion ---------- [Form] Fix handling of empty_data's \Closure value in Date/Time form types | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #33188 | License | MIT | Doc PR | - Basically this would solve the posibility to pass a `\Closure` to the `empty_data` option for Date/Time form types. > https://symfony.com/doc/current/reference/forms/types/form.html#empty-data > If a form is compound, you can set empty_data as an array, object or **closure**. See the [How to Configure empty Data](https://symfony.com/doc/current/form/use_empty_data.html) for a Form Class article for more details about these options. Also related to symfony/symfony#29182 Commits ------- 4939f0e323 Fix handling of empty_data's \Closure value in Date/Time form types