Valid strtotime() format when time is left empty

Date-type laravel validation ("date", "before", and "after") may not be used with datetime widgets containing empty time fields because they are not in a valid strtotime() format (example: 2014-12-27 :00).

This extra check ensures a valid strtotime() format by only adding the ":00" seconds value when a time value is present.
This commit is contained in:
Scott Bedard 2014-12-27 17:33:27 -05:00
parent 9c8fcd148c
commit 8286880148

View File

@ -126,8 +126,8 @@ class DatePicker extends FormWidgetBase
return null;
}
if ($this->mode == 'datetime') {
$value .= ' ' . post(self::TIME_PREFIX.$this->formField->getName(false)) . ':00';
if ($this->mode == 'datetime' && $timeValue = post(self::TIME_PREFIX.$this->formField->getName(false))) {
$value .= ' ' . $timeValue . ':00';
}
elseif ($this->mode == 'time') {
$value .= ':00';