BUGFIX: Don't make blank dates show 1/1/1970

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@66891 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Andrew O'Neil 2008-11-28 01:26:44 +00:00 committed by Sam Minnee
parent 1aeaed7fc4
commit 025d2b2498

View File

@ -99,8 +99,11 @@ class DateField_Disabled extends DateField {
protected $disabled = true; protected $disabled = true;
function setValue($val) { function setValue($val) {
if($val && $val != "0000-00-00") $this->value = date('d/m/Y', strtotime($val)); if(is_string($val) && preg_match('/^([\d]{2,4})-([\d]{1,2})-([\d]{1,2})/', $val)) {
else $this->value = '('._t('DateField.NODATESET', 'No date set').')'; $this->value = preg_replace('/^([\d]{2,4})-([\d]{1,2})-([\d]{1,2})/','\\3/\\2/\\1', $val);
} else {
$this->value = $val;
}
} }
function Field() { function Field() {