Permalink
Browse files

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)
  • Loading branch information...
1 parent 755a95e commit e225cffcf8828bf19b173bff695f47a1d6d58cfb @dhensby dhensby committed Jun 28, 2013
Showing with 2 additions and 2 deletions.
  1. +2 −2 forms/DateField.php
View
@@ -367,7 +367,7 @@ public function validate($validator) {
} 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 @@ public function validate($validator) {
} 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',

0 comments on commit e225cff

Please sign in to comment.