BUGFIX DateField with setConfig('dmyfields') now validates TRUE for empty values (fixes #5458)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@103450 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-04-25 21:18:44 +00:00 committed by Sam Minnee
parent 219c5ff893
commit 577857b98c
2 changed files with 7 additions and 1 deletions

View File

@ -351,7 +351,7 @@ JS;
// 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 File

@ -119,6 +119,12 @@ class DateFieldTest extends SapphireTest {
$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()));