Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit802c67c

Browse files
committed
Change datetime input to datetime-local
1 parentf7d9701 commit802c67c

File tree

4 files changed

+10
-15
lines changed

4 files changed

+10
-15
lines changed

‎src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,12 @@ class DateTimeType extends AbstractType
3434

3535
/**
3636
* This is not quite the HTML5 format yet, because ICU lacks the
37-
* capability of parsing and generating RFC 3339 dates, which
38-
* are like the below pattern but with a timezone suffix. The
39-
* timezone suffix is.
40-
*
41-
* * "Z" for UTC
42-
* * "(-|+)HH:mm" for other timezones (note the colon!)
37+
* capability of parsing and generating RFC 3339 dates.
4338
*
4439
* For more information see:
4540
*
4641
* http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax
47-
*http://www.w3.org/TR/html-markup/input.datetime.html
42+
*https://www.w3.org/TR/html5/sec-forms.html#local-date-and-time-state-typedatetimelocal
4843
* http://tools.ietf.org/html/rfc3339
4944
*
5045
* An ICU ticket was created:
@@ -54,7 +49,7 @@ class DateTimeType extends AbstractType
5449
* yet. To temporarily circumvent this issue, DateTimeToRfc3339Transformer
5550
* is used when the format matches this constant.
5651
*/
57-
constHTML5_FORMAT ="yyyy-MM-dd'T'HH:mm:ssZZZZZ";
52+
constHTML5_FORMAT ="yyyy-MM-dd'T'HH:mm:ss";
5853

5954
privatestatic$acceptedFormats =array(
6055
\IntlDateFormatter::FULL,
@@ -192,7 +187,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
192187
// * the format matches the one expected by HTML5
193188
// * the html5 is set to true
194189
if ($options['html5'] &&'single_text' ===$options['widget'] &&self::HTML5_FORMAT ===$options['format']) {
195-
$view->vars['type'] ='datetime';
190+
$view->vars['type'] ='datetime-local';
196191
}
197192
}
198193

‎src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,7 @@ public function testDateTimeWithWidgetSingleText()
15251525

15261526
$this->assertWidgetMatchesXpath($form->createView(),array('attr' =>array('class' =>'my&class')),
15271527
'/input
1528-
[@type="datetime"]
1528+
[@type="datetime-local"]
15291529
[@name="name"]
15301530
[@class="my&class form-control"]
15311531
[@value="2011-02-03T04:05:06Z"]
@@ -1546,7 +1546,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
15461546

15471547
$this->assertWidgetMatchesXpath($form->createView(),array('attr' =>array('class' =>'my&class')),
15481548
'/input
1549-
[@type="datetime"]
1549+
[@type="datetime-local"]
15501550
[@name="name"]
15511551
[@class="my&class form-control"]
15521552
[@value="2011-02-03T04:05:06Z"]

‎src/Symfony/Component/Form/Tests/AbstractLayoutTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,7 +1426,7 @@ public function testDateTimeWithWidgetSingleText()
14261426

14271427
$this->assertWidgetMatchesXpath($form->createView(),array(),
14281428
'/input
1429-
[@type="datetime"]
1429+
[@type="datetime-local"]
14301430
[@name="name"]
14311431
[@value="2011-02-03T04:05:06Z"]
14321432
'
@@ -1446,7 +1446,7 @@ public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets()
14461446

14471447
$this->assertWidgetMatchesXpath($form->createView(),array(),
14481448
'/input
1449-
[@type="datetime"]
1449+
[@type="datetime-local"]
14501450
[@name="name"]
14511451
[@value="2011-02-03T04:05:06Z"]
14521452
'

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function testSingleTextWidgetShouldUseTheRightInputType()
283283
))
284284
->createView();
285285

286-
$this->assertEquals('datetime',$view->vars['type']);
286+
$this->assertEquals('datetime-local',$view->vars['type']);
287287
}
288288

289289
publicfunctiontestPassDefaultPlaceholderToViewIfNotRequired()
@@ -433,7 +433,7 @@ public function testPassHtml5TypeIfSingleTextAndHtml5Format()
433433
))
434434
->createView();
435435

436-
$this->assertSame('datetime',$view->vars['type']);
436+
$this->assertSame('datetime-local',$view->vars['type']);
437437
}
438438

439439
publicfunctiontestDontPassHtml5TypeIfHtml5NotAllowed()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp