mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
755a95e3f7
commit
e225cffcf8
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user