From df5681371dfd1733fcfafe4237a934f807511895 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 31 Mar 2017 14:12:56 +1300 Subject: [PATCH 1/2] Added TimeField with setHTML5(true) --- code/BasicFieldsTestPage.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index 36efa06..b64b391 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -55,6 +55,7 @@ class BasicFieldsTestPage extends TestPage 'Text' => 'Varchar', 'Textarea' => 'Text', 'Time' => 'Time', + 'TimeHTML5' => 'Time', 'ToggleCompositeTextField1' => 'Varchar', 'ToggleCompositeDropdownField' => 'Varchar', 'Validated' => 'Text', @@ -152,6 +153,7 @@ class BasicFieldsTestPage extends TestPage 'Text' => 'My value (ä!)', 'Textarea' => 'My value (ä!)', 'Time' => "23:59", + 'TimeHTML5' => "23:59", 'ToggleCompositeTextField1' => 'My value (ä!)', 'Validated' => '1', ); @@ -234,16 +236,18 @@ class BasicFieldsTestPage extends TestPage // All these date/time fields generally have issues saving directly in the CMS $fields->addFieldsToTab('Root.DateTime', array( - $calendarDateField = Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with calendar'), + Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with HTML5') + ->setHTML5(true), Object::create('SilverStripe\\Forms\\DateField', 'Date', 'DateField'), - $dmyDateField = Object::create('SilverStripe\\Forms\\SeparatedDateField', 'DMYDate', 'DateField with separate fields'), + Object::create('SilverStripe\\Forms\\SeparatedDateField', 'DMYDate', 'DateField with separate fields'), Object::create('SilverStripe\\Forms\\TimeField', 'Time', 'TimeField'), + Object::create('SilverStripe\\Forms\\TimeField', 'TimeHTML5', 'TimeField with HTML5') + ->setHTML5(true), Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTime', 'DateTime'), $dateTimeShowCalendar = Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar') )); - $calendarDateField->setShowCalendar(true); - $dateTimeShowCalendar->getDateField()->setShowCalendar(true); // $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true); + $dateTimeShowCalendar->getDateField()->setHTML5(true); $dateTimeShowCalendar->setRightTitle('Right title'); $fields->addFieldsToTab('Root.File', array( From 097e136525e849c1e8a620bce9d49ca8b69e9e3f Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Sun, 2 Apr 2017 11:26:33 +1200 Subject: [PATCH 2/2] Use HTML5 date (with min-date case) --- code/BasicFieldsTestPage.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/code/BasicFieldsTestPage.php b/code/BasicFieldsTestPage.php index b64b391..6312268 100644 --- a/code/BasicFieldsTestPage.php +++ b/code/BasicFieldsTestPage.php @@ -192,8 +192,7 @@ class BasicFieldsTestPage extends TestPage Object::create('SilverStripe\\Forms\\TextField', 'Text'), Object::create('SilverStripe\\Forms\\HTMLEditor\\HTMLEditorField', 'HTMLField', 'HTMLField'), Object::create('SilverStripe\\Forms\\EmailField', 'Email'), - Object::create('SilverStripe\\Forms\\PasswordField', 'Password'), - Object::create('SilverStripe\\Forms\\ConfirmedPasswordField', 'ConfirmedPassword') +// Object::create('SilverStripe\\Forms\\ConfirmedPasswordField', 'ConfirmedPassword') )); $fields->addFieldsToTab('Root.Numeric', array( @@ -235,19 +234,20 @@ class BasicFieldsTestPage extends TestPage )); // All these date/time fields generally have issues saving directly in the CMS + $minDate = date('Y-m-d', strtotime('-7 days')); $fields->addFieldsToTab('Root.DateTime', array( - Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with HTML5') - ->setHTML5(true), - Object::create('SilverStripe\\Forms\\DateField', 'Date', 'DateField'), - Object::create('SilverStripe\\Forms\\SeparatedDateField', 'DMYDate', 'DateField with separate fields'), - Object::create('SilverStripe\\Forms\\TimeField', 'Time', 'TimeField'), - Object::create('SilverStripe\\Forms\\TimeField', 'TimeHTML5', 'TimeField with HTML5') - ->setHTML5(true), - Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTime', 'DateTime'), - $dateTimeShowCalendar = Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTimeWithCalendar', 'DateTime with calendar') + Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with HTML5 (min date: ' . $minDate . ')') + ->setMinDate($minDate), + Object::create('SilverStripe\\Forms\\DateField', 'Date', 'DateField without HTML5') + ->setHTML5(false), + Object::create('SilverStripe\\Forms\\TimeField', 'Time', 'TimeField without HTML5') + ->setHTML5(false), + Object::create('SilverStripe\\Forms\\TimeField', 'TimeHTML5', 'TimeField with HTML5'), + $dateTime = Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTime', 'DateTime without HTML5'), + $dateTimeShowCalendar = Object::create('SilverStripe\\Forms\\DatetimeField', 'DateTimeWithCalendar', 'DateTime with HTML5') )); -// $dateTimeShowCalendar->getTimeField()->setConfig('showdropdown', true); - $dateTimeShowCalendar->getDateField()->setHTML5(true); + $dateTime->getDateField()->setHTML5(true); + $dateTime->getTimeField()->setHTML5(true); $dateTimeShowCalendar->setRightTitle('Right title'); $fields->addFieldsToTab('Root.File', array(