diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php index 9cd25ed7789c2..2662c3b8a2dd9 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php @@ -34,17 +34,12 @@ class DateTimeType extends AbstractType /** * This is not quite the HTML5 format yet, because ICU lacks the - * capability of parsing and generating RFC 3339 dates, which - * are like the below pattern but with a timezone suffix. The - * timezone suffix is. - * - * * "Z" for UTC - * * "(-|+)HH:mm" for other timezones (note the colon!) + * capability of parsing and generating RFC 3339 dates. * * For more information see: * * http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax - * http://www.w3.org/TR/html-markup/input.datetime.html + * https://www.w3.org/TR/html5/sec-forms.html#local-date-and-time-state-typedatetimelocal * http://tools.ietf.org/html/rfc3339 * * An ICU ticket was created: @@ -54,7 +49,7 @@ class DateTimeType extends AbstractType * yet. To temporarily circumvent this issue, DateTimeToRfc3339Transformer * is used when the format matches this constant. */ - const HTML5_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"; + const HTML5_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; private static $acceptedFormats = array( \IntlDateFormatter::FULL, @@ -192,7 +187,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) // * the format matches the one expected by HTML5 // * the html5 is set to true if ($options['html5'] && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { - $view->vars['type'] = 'datetime'; + $view->vars['type'] = 'datetime-local'; } } diff --git a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php index 8d9b11d39a401..9b8ffd3abd539 100644 --- a/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php @@ -1525,7 +1525,7 @@ public function testDateTimeWithWidgetSingleText() $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input - [@type="datetime"] + [@type="datetime-local"] [@name="name"] [@class="my&class form-control"] [@value="2011-02-03T04:05:06Z"] @@ -1546,7 +1546,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), '/input - [@type="datetime"] + [@type="datetime-local"] [@name="name"] [@class="my&class form-control"] [@value="2011-02-03T04:05:06Z"] diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 752cddbdd798a..2d0bbf97be379 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -1426,7 +1426,7 @@ public function testDateTimeWithWidgetSingleText() $this->assertWidgetMatchesXpath($form->createView(), array(), '/input - [@type="datetime"] + [@type="datetime-local"] [@name="name"] [@value="2011-02-03T04:05:06Z"] ' @@ -1446,7 +1446,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() $this->assertWidgetMatchesXpath($form->createView(), array(), '/input - [@type="datetime"] + [@type="datetime-local"] [@name="name"] [@value="2011-02-03T04:05:06Z"] ' diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index 1c48a777edc97..073cf8726d91b 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -283,7 +283,7 @@ public function testSingleTextWidgetShouldUseTheRightInputType() )) ->createView(); - $this->assertEquals('datetime', $view->vars['type']); + $this->assertEquals('datetime-local', $view->vars['type']); } public function testPassDefaultPlaceholderToViewIfNotRequired() @@ -433,7 +433,7 @@ public function testPassHtml5TypeIfSingleTextAndHtml5Format() )) ->createView(); - $this->assertSame('datetime', $view->vars['type']); + $this->assertSame('datetime-local', $view->vars['type']); } public function testDontPassHtml5TypeIfHtml5NotAllowed()