Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Form] Fix DateTimeType html5 input format#28372
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
374dfbf to67a95f4Compare| useSymfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer; | ||
| useSymfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; | ||
| useSymfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; | ||
| useSymfony\Component\Form\Extension\Core\DataTransformer\DateTimeToHTML5DateTimeLocalTransformer; |
nicolas-grekasSep 6, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
case mismatch (see failing tests): should beHtml5
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.
Oops! Thanks.
nicolas-grekas left a comment
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.
LGTM with just one minor comment
| */ | ||
| class DateTimeToHtml5DateTimeLocalTransformerextends BaseDateTimeTransformer | ||
| { | ||
| constHTML5_FORMAT ="Y-m-d\TH: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 use single quotes
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.
Fixed, I've also put '\T' in the middle, as it looks more correct, it works with single\ because\T is not a valid combo, but really for a literal\ it should be\\
javiereguiluz commentedSep 10, 2018
This is a bit confusing:
|
franzwilding commentedSep 10, 2018
@javiereguiluz The problem is, that Chrome do not support |
javiereguiluz commentedSep 10, 2018
I see. In the past, we usually ignored issues like this considering them as browsers bugs (I remember a problem with a Safari-only behavior). But this is frustrating for users and Chrome is the most popular browser ... so it will be a tough decision. |
franzwilding commentedSep 10, 2018
@javiereguiluz I think in this case it is less a browser specific hack and more a more correct implementation of the datetime-local draft specs. I think the whole idea of datetime-local is to be a datetime field without a timezone, this is also the description of the datetime-local field:https://www.w3.org/TR/2012/WD-html-markup-20120315/input.datetime-local.html Also, when you see the reference of the date + time format (https://www.w3.org/TR/2012/WD-html-markup-20120315/datatypes.html#form.data.datetime-local) it clearly says that there should not be a timezone suffix. |
javiereguiluz commentedSep 10, 2018
@franzwilding thanks for the details. It's more clear to me now. Approved it! |
mcfedr commentedSep 10, 2018
I refered to the whatwg spec, which does not include |
| } | ||
| try { | ||
| $dateTime =new \DateTime($dateTimeLocal,new \DateTimeZone($this->outputTimezone)); |
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.
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.
Makes sense, I've added something similar here.
d6f0029 toe21a1a4Comparenicolas-grekas commentedSep 17, 2018
Thank you@mcfedr. |
…mcfedr)This PR was merged into the 2.8 branch.Discussion----------[Form] Fix DateTimeType html5 input format| Q | A| ------------- | ---| Branch? | 2.8| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#27233,#27254| License | MIT| Doc PR | N/AFix DateTimeType' HTML input format according to HTML specs. Currently `DateTimeType` produces html with format `yyyy-MM-dd'T'HH:mm:ssZ` but the HTML5 spec expects `yyyy-MM-dd'T'HH:mm:ss` (i.e. no `Z`). Chrome presents an empty date picker meaning edits or having a default date are broken.Also the reverseTransform was expect to have a timezone attached, which it does not - and incorrectly marks it as being a UTC time in this case, instead of using the Transformers output TZ.This is same as@franzwilding#27254 but with change to just straight use of `DateTime::format` and handling TZ in reverseTransformCommits-------e21a1a4 Added relevent links for parsing to the phpdoc4f06f15 Add stricter checking for valid date time string253d0a6 [Form] Fix DateTimeType html5 input format
nicolas-grekas commentedSep 18, 2018
Could anyone please have a look at why this PR makes tests for 4.1 to fail? |
This PR was submitted for the master branch but it was merged into the 4.1 branch instead (closes#28504).Discussion----------[Form] Fix expected values in datetime-local test| Q | A| ------------- | ---| Branch? | master| Bug fix? | yes| New feature? | no| BC breaks? | no| Deprecations? | no| Tests pass? | yes| Fixed tickets |#28372| License | MIT| Doc PR | N/ACommits-------5ed8b27 Fix expected values in datetime-local test
Uh oh!
There was an error while loading.Please reload this page.
Fix DateTimeType' HTML input format according to HTML specs. Currently
DateTimeTypeproduces html with formatyyyy-MM-dd'T'HH:mm:ssZbut the HTML5 spec expectsyyyy-MM-dd'T'HH:mm:ss(i.e. noZ). Chrome presents an empty date picker meaning edits or having a default date are broken.Also the reverseTransform was expect to have a timezone attached, which it does not - and incorrectly marks it as being a UTC time in this case, instead of using the Transformers output TZ.
This is same as@franzwilding#27254 but with change to just straight use of
DateTime::formatand handling TZ in reverseTransform