Skip to content

[Form] Add input_format option to DateType and DateTimeType #29887

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

fancyweb
Copy link
Contributor

@fancyweb fancyweb commented Jan 14, 2019

Q A
Branch? master
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #29883
License MIT
Doc PR symfony/symfony-docs#10882

Add a new option to specify the date format when using the string input type.

@@ -251,6 +251,7 @@ public function configureOptions(OptionsResolver $resolver)
'empty_data' => function (Options $options) {
return $options['compound'] ? array() : '';
},
'input_format' => 'Y-m-d H:i:s',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we set the default here or rely on the transformer default ? IMHO, it's better here so the form type and the transformer are more decoupled.

@@ -292,6 +293,8 @@ public function configureOptions(OptionsResolver $resolver)
'text',
'choice',
));

$resolver->setAllowedTypes('input_format', 'string');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should we validate the passed input_format ?

@fancyweb fancyweb force-pushed the add-input-format-option-to-date-time-form-types branch from a7303a6 to 12c80e8 Compare January 14, 2019 20:51
@fancyweb fancyweb force-pushed the add-input-format-option-to-date-time-form-types branch 2 times, most recently from 164ec2e to b4b1296 Compare January 17, 2019 20:48
@nicolas-grekas nicolas-grekas added this to the next milestone Jan 24, 2019
@nicolas-grekas nicolas-grekas requested a review from xabbuh January 24, 2019 19:53
@fancyweb fancyweb force-pushed the add-input-format-option-to-date-time-form-types branch from b4b1296 to 869bbde Compare January 25, 2019 19:36
@xabbuh
Copy link
Member

xabbuh commented Feb 2, 2019

@fancyweb Can you rebase here?

@fancyweb fancyweb force-pushed the add-input-format-option-to-date-time-form-types branch from 869bbde to 7de0120 Compare February 2, 2019 09:04
@@ -317,6 +318,8 @@ public function configureOptions(OptionsResolver $resolver)

return '';
});

$resolver->setAllowedTypes('input_format', 'string');
Copy link
Member

Choose a reason for hiding this comment

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

return sprintf('Using the "date_format" option of %s when the "widget" option is set to "single_text" is deprecated since Symfony 4.3 and will lead to an exception in 5.0.', self::class);
//throw new LogicException(sprintf('Cannot use the "date_format" option of the %s when the "widget" option is set to "single_text".', self::class));

As we are going to do with the time_widget option, I wonder if we should throw an exception when the input_format is passed and the value of input is not strictly equal to string'.

@xabbuh
Copy link
Member

xabbuh commented Feb 15, 2019

@fancyweb Can you rebase here?

@fancyweb fancyweb force-pushed the add-input-format-option-to-date-time-form-types branch from 7de0120 to ef26ad0 Compare February 16, 2019 08:24
@fancyweb fancyweb force-pushed the add-input-format-option-to-date-time-form-types branch from ef26ad0 to c8240a0 Compare February 18, 2019 18:20
@xabbuh
Copy link
Member

xabbuh commented Feb 20, 2019

Thank you @fancyweb.

@xabbuh xabbuh merged commit c8240a0 into symfony:master Feb 20, 2019
xabbuh added a commit that referenced this pull request Feb 20, 2019
…eType (fancyweb)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Form] Add input_format option to DateType and DateTimeType

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29883
| License       | MIT
| Doc PR        | symfony/symfony-docs#10882

Add a new option to specify the date format when using the `string` input type.

Commits
-------

c8240a0 [Form] Add input_format option to DateType and DateTimeType
fabpot added a commit that referenced this pull request Mar 3, 2019
…xabbuh)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[Form] be able to specify the input format for times

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets |
| License       | MIT
| Doc PR        |

This expands the work started in #29887 to also allow to configure the input format for string inputs in the `TimeType`.

Commits
-------

2d9bc18 be able to specify the input format for times
javiereguiluz added a commit to symfony/symfony-docs that referenced this pull request Mar 7, 2019
… and TimeType (fancyweb)

This PR was squashed before being merged into the master branch (closes #10882).

Discussion
----------

[Form] Add input_format option to DateType, DateTimeType and TimeType

Related Symfony PRs : symfony/symfony#29887 and symfony/symfony#30358

Commits
-------

8fc1b53 [Form] Add input_format option to DateType, DateTimeType and TimeType
@nicolas-grekas nicolas-grekas modified the milestones: next, 4.3 Apr 30, 2019
@fabpot fabpot mentioned this pull request May 9, 2019
@fancyweb fancyweb deleted the add-input-format-option-to-date-time-form-types branch August 9, 2019 07:14
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.

5 participants