From 025d2b2498771ed5c4bd68fe4d50125495ff68a4 Mon Sep 17 00:00:00 2001 From: Andrew O'Neil Date: Fri, 28 Nov 2008 01:26:44 +0000 Subject: [PATCH] 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 --- forms/DateField.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/forms/DateField.php b/forms/DateField.php index 528d19da2..524c79c48 100755 --- a/forms/DateField.php +++ b/forms/DateField.php @@ -99,8 +99,11 @@ class DateField_Disabled extends DateField { protected $disabled = true; function setValue($val) { - if($val && $val != "0000-00-00") $this->value = date('d/m/Y', strtotime($val)); - else $this->value = '('._t('DateField.NODATESET', 'No date set').')'; + if(is_string($val) && preg_match('/^([\d]{2,4})-([\d]{1,2})-([\d]{1,2})/', $val)) { + $this->value = preg_replace('/^([\d]{2,4})-([\d]{1,2})-([\d]{1,2})/','\\3/\\2/\\1', $val); + } else { + $this->value = $val; + } } function Field() { @@ -136,4 +139,4 @@ class DateField_Disabled extends DateField { return true; } } -?> \ No newline at end of file +?>