Skip to content

[Form] DateTimeType value does not work for HTML5 datetime-local input in chrome #27233

@franzwilding

Description

@franzwilding

Symfony version(s) affected: 4

Description
DateTimeType passes values in format yyyy-MM-dd'T'HH:mm:ssZ to the html5 input element. However chrome expects the format yyyy-MM-dd'T'HH:mm:ss for datetime-local input types.

How to reproduce

  • Create a form with a DateTimeType child, widget = 'single_text'
  • Pass data to the form
  • Render the form in chrome (v66)
  • An empty datetime input will be rendered

Possible Solution
When trying to set the format to DateTimeType::HTML5_FORMAT (yyyy-MM-dd'T'HH:mm:ss), the DateTimeType will automatically add the DateTimeToRfc3339Transformer viewTransformer which uses the format yyyy-MM-dd'T'HH:mm:ssZ.

  • One solution would be make the use of DateTimeToRfc3339Transformer optional
  • Another solution would be to get rid of the trailing Z in DateTimeToRfc3339Transformer, which would also be valid in RFC3339 I think.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions