FIX Empty Datefield with defined min or max has non-object error thrown

When submitting a Datefield with no value but with a min / max config date, the validate() function attempts to access a function on $this->valueObj (which is a non-object)
This commit is contained in:
Daniel Hensby 2013-06-28 18:49:50 +01:00
parent 755a95e3f7
commit e225cffcf8

View File

@ -367,7 +367,7 @@ class DateField extends TextField {
} else {
$minDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($min)), $this->getConfig('datavalueformat'));
}
if(!$this->valueObj->isLater($minDate) && !$this->valueObj->equals($minDate)) {
if(!$this->valueObj || (!$this->valueObj->isLater($minDate) && !$this->valueObj->equals($minDate))) {
$validator->validationError(
$this->name,
_t(
@ -388,7 +388,7 @@ class DateField extends TextField {
} else {
$maxDate = new Zend_Date(strftime('%Y-%m-%d', strtotime($max)), $this->getConfig('datavalueformat'));
}
if(!$this->valueObj->isEarlier($maxDate) && !$this->valueObj->equals($maxDate)) {
if(!$this->valueObj || (!$this->valueObj->isEarlier($maxDate) && !$this->valueObj->equals($maxDate))) {
$validator->validationError(
$this->name,
_t('DateField.VALIDDATEMAXDATE',