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] Fixed empty data for compound date types #29182

Merged
merged 1 commit into from Nov 15, 2018

Conversation

HeahDude
Copy link
Contributor

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 ~

@nicolas-grekas nicolas-grekas added this to the 2.8 milestone Nov 12, 2018
@HeahDude
Copy link
Contributor Author

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.

@nicolas-grekas
Copy link
Member

Thank you @HeahDude.

@nicolas-grekas nicolas-grekas merged commit 9bab1e8 into symfony:2.8 Nov 15, 2018
nicolas-grekas added a commit that referenced this pull request Nov 15, 2018
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
@HeahDude HeahDude deleted the fix-date-empty-data-compound branch November 15, 2018 17:14
@fabpot fabpot mentioned this pull request Nov 16, 2018
nicolas-grekas added a commit that referenced this pull request Nov 20, 2018
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
This was referenced Nov 26, 2018
@@ -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() : '';
Copy link

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?

Copy link

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

Copy link
Member

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?

Copy link

@anyt anyt Jan 4, 2019

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!

fabpot added a commit that referenced this pull request Feb 3, 2020
…/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
symfony-splitter pushed a commit to symfony/form that referenced this pull request Feb 3, 2020
…/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
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

5 participants