Permalink
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...
1 parent 5ba7760 commit a2f6487fa330a3bfd6517c7dc950213b3a7734e2 @sminnee sminnee committed Oct 13, 2010
Showing with 7 additions and 1 deletion.
  1. +1 −1 forms/DateField.php
  2. +6 −0 tests/forms/DateFieldTest.php
View
@@ -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));
}
@@ -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()));

0 comments on commit a2f6487

Please sign in to comment.