-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[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
[Form] Add input_format option to DateType and DateTimeType #29887
Conversation
| 'empty_data' => function (Options $options) { | ||
| return $options['compound'] ? array() : ''; | ||
| }, | ||
| 'input_format' => 'Y-m-d H:i:s', |
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.
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.
| 'choice', | ||
| )); | ||
|
|
||
| $resolver->setAllowedTypes('input_format', 'string'); |
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.
Should we validate the passed input_format ?
a7303a6 to
12c80e8
Compare
164ec2e to
b4b1296
Compare
b4b1296 to
869bbde
Compare
|
@fancyweb Can you rebase here? |
869bbde to
7de0120
Compare
| return ''; | ||
| }); | ||
|
|
||
| $resolver->setAllowedTypes('input_format', 'string'); |
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.
symfony/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php
Lines 298 to 299 in a6a1be8
| 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'.
|
@fancyweb Can you rebase here? |
7de0120 to
ef26ad0
Compare
ef26ad0 to
c8240a0
Compare
|
Thank you @fancyweb. |
…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
…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
… 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
Add a new option to specify the date format when using the
stringinput type.