Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

BUGFIX DateField with setConfig('dmyfields') now validates TRUE for e…

…mpty values (fixes #5458) (from r103450)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112140 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
commit a2f6487fa330a3bfd6517c7dc950213b3a7734e2 1 parent 5ba7760
@sminnee sminnee authored
Showing with 7 additions and 1 deletion.
  1. +1 −1  forms/DateField.php
  2. +6 −0 tests/forms/DateFieldTest.php
View
2  forms/DateField.php
@@ -351,7 +351,7 @@ function validate($validator) {
// date format
if($this->getConfig('dmyfields')) {
- $valid = ($this->validateArrayValue($this->value));
+ $valid = (!$this->value || $this->validateArrayValue($this->value));
} else {
$valid = (Zend_Date::isDate($this->value, $this->getConfig('dateformat'), $this->locale));
}
View
6 tests/forms/DateFieldTest.php
@@ -119,6 +119,12 @@ function testValidateArray() {
$f->setValue(array('day' => 29, 'month' => 03, 'year' => 2003));
$this->assertTrue($f->validate(new RequiredFields()));
+ $f->setValue(null);
+ $this->assertTrue($f->validate(new RequiredFields()), 'NULL values are validating TRUE');
+
+ $f->setValue(array());
+ $this->assertTrue($f->validate(new RequiredFields()), 'Empty array values are validating TRUE');
+
// TODO Fix array validation
// $f = new DateField('Date', 'Date', array('day' => 9999, 'month' => 9999, 'year' => 9999));
// $this->assertFalse($f->validate(new RequiredFields()));
Please sign in to comment.
Something went wrong with that request. Please try again.