BUGFIX Respecting field specific locale settings in DatetimeField and DateField when validating and saving values (fixes #5931, thanks Tjofras)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@110889 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-09-17 00:01:48 +00:00 committed by Sam Minnee
parent 31e9726ace
commit 316ef6c106
2 changed files with 7 additions and 6 deletions

View File

@ -151,8 +151,8 @@ class DateField extends TextField {
$this->value = $this->valueObj->toArray();
}
// load ISO date from database (usually through Form->loadDataForm())
else if(!empty($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'))) {
$this->valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'));
else if(!empty($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'), $this->locale)) {
$this->valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'), $this->locale);
$this->value = $this->valueObj->toArray();
}
else {
@ -166,12 +166,13 @@ class DateField extends TextField {
// (en_NZ for 3rd of April, definetly not yyyy-MM-dd)
if(!empty($val) && Zend_Date::isDate($val, $this->getConfig('dateformat'), $this->locale)) {
$this->valueObj = new Zend_Date($val, $this->getConfig('dateformat'), $this->locale);
$this->value = $this->valueObj->get($this->getConfig('dateformat'));
$this->value = $this->valueObj->get($this->getConfig('dateformat'), $this->locale);
}
// load ISO date from database (usually through Form->loadDataForm())
else if(!empty($val) && Zend_Date::isDate($val, $this->getConfig('datavalueformat'))) {
$this->valueObj = new Zend_Date($val, $this->getConfig('datavalueformat'));
$this->value = $this->valueObj->get($this->getConfig('dateformat'));
$this->value = $this->valueObj->get($this->getConfig('dateformat'), $this->locale);
}
else {
$this->value = $val;

View File

@ -72,10 +72,10 @@ class DatetimeField extends FormField {
if($this->dateField->getConfig('dmyfields')) {
$this->dateField->setValue($valueObj->toArray());
} else {
$this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat')));
$this->dateField->setValue($valueObj->get($this->dateField->getConfig('dateformat'), $this->locale));
}
// set time
$this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat')));
$this->timeField->setValue($valueObj->get($this->timeField->getConfig('timeformat'), $this->locale));
}
// Setting from form submission
elseif(is_array($val) && array_key_exists('date', $val) && array_key_exists('time', $val)) {