Align date minimums with db defaults

Avoid validation errors by default
This commit is contained in:
Ingo Schommer 2017-04-26 10:32:02 +12:00
parent 902151603c
commit 8cb15a45de

View File

@ -114,14 +114,14 @@ class BasicFieldsTestPage extends TestPage
$thirdCat = $cats->offsetGet(2); $thirdCat = $cats->offsetGet(2);
return array( return array(
'CalendarDate' => "2002-10-23", 'CalendarDate' => "2017-01-31",
'Checkbox' => 1, 'Checkbox' => 1,
// 'CheckboxSet' => null, // 'CheckboxSet' => null,
'ConfirmedPassword' => 'secret', 'ConfirmedPassword' => 'secret',
'CreditCard' => '4000400040004111', 'CreditCard' => '4000400040004111',
'Date' => "2002-10-23", 'Date' => "2017-01-31",
'DateTime' => "2002-10-23 23:59", 'DateTime' => "2017-01-31 23:59",
'DateTimeWithCalendar' => "2002-10-23 23:59", 'DateTimeWithCalendar' => "2017-01-31 23:59",
'DropdownID' => $firstCat->ID, 'DropdownID' => $firstCat->ID,
'Email' => 'test@test.com', 'Email' => 'test@test.com',
'GroupedDropdownID' => $firstCat->ID, 'GroupedDropdownID' => $firstCat->ID,
@ -231,13 +231,14 @@ class BasicFieldsTestPage extends TestPage
)) ))
)); ));
// All these date/time fields generally have issues saving directly in the CMS $minDate = '2017-01-01';
$minDate = date('Y-m-d', strtotime('-7 days')); $minDateTime = '2017-01-01 23:59:00';
$fields->addFieldsToTab('Root.DateTime', array( $fields->addFieldsToTab('Root.DateTime', array(
Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with HTML5 (min date: ' . $minDate . ')') Object::create('SilverStripe\\Forms\\DateField', 'CalendarDate', 'DateField with HTML5 (min date: ' . $minDate . ')')
->setMinDate($minDate), ->setMinDate($minDate),
Object::create('SilverStripe\\Forms\\DateField', 'Date', 'DateField without HTML5') Object::create('SilverStripe\\Forms\\DateField', 'Date', 'DateField without HTML5 (min date: ' . $minDate . ')')
->setHTML5(false), ->setHTML5(false)
->setMinDate($minDate),
Object::create('SilverStripe\\Forms\\TimeField', 'Time', 'TimeField without HTML5') Object::create('SilverStripe\\Forms\\TimeField', 'Time', 'TimeField without HTML5')
->setHTML5(false), ->setHTML5(false),
Object::create('SilverStripe\\Forms\\TimeField', 'TimeHTML5', 'TimeField with HTML5'), Object::create('SilverStripe\\Forms\\TimeField', 'TimeHTML5', 'TimeField with HTML5'),