|
|
@@ -2116,7 +2116,12 @@ class FormHelper extends AppHelper {
|
|
|
$attributes = $this->_dateTimeSelected('day', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('d');
|
|
|
+ $Date = date_create($attributes['value']);
|
|
|
+ if ($Date) {
|
|
|
+ $attributes['value'] = $Date->format('d');
|
|
|
+ } else {
|
|
|
+ $attributes['value'] = null;
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -2163,7 +2168,12 @@ class FormHelper extends AppHelper {
|
|
|
}
|
|
|
|
|
|
if (strlen($attributes['value']) > 4 || $attributes['value'] === 'now') {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('Y');
|
|
|
+ $Date = date_create($attributes['value']);
|
|
|
+ if ($Date) {
|
|
|
+ $attributes['value'] = $Date->format('Y');
|
|
|
+ } else {
|
|
|
+ $attributes['value'] = null;
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -2199,7 +2209,12 @@ class FormHelper extends AppHelper {
|
|
|
$attributes = $this->_dateTimeSelected('month', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('m');
|
|
|
+ $Date = date_create($attributes['value']);
|
|
|
+ if ($Date) {
|
|
|
+ $attributes['value'] = $Date->format('m');
|
|
|
+ } else {
|
|
|
+ $attributes['value'] = null;
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -2235,11 +2250,15 @@ class FormHelper extends AppHelper {
|
|
|
$attributes = $this->_dateTimeSelected('hour', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $Date = new DateTime($attributes['value']);
|
|
|
- if ($format24Hours) {
|
|
|
- $attributes['value'] = $Date->format('H');
|
|
|
- } else {
|
|
|
- $attributes['value'] = $Date->format('g');
|
|
|
+ try {
|
|
|
+ $Date = new DateTime($attributes['value']);
|
|
|
+ if ($format24Hours) {
|
|
|
+ $attributes['value'] = $Date->format('H');
|
|
|
+ } else {
|
|
|
+ $attributes['value'] = $Date->format('g');
|
|
|
+ }
|
|
|
+ } catch (Exception $e) {
|
|
|
+ $attributes['value'] = null;
|
|
|
}
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
@@ -2278,7 +2297,12 @@ class FormHelper extends AppHelper {
|
|
|
$attributes = $this->_dateTimeSelected('min', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('i');
|
|
|
+ $Date = date_create($attributes['value']);
|
|
|
+ if ($Date) {
|
|
|
+ $attributes['value'] = $Date->format('i');
|
|
|
+ } else {
|
|
|
+ $attributes['value'] = null;
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -2329,7 +2353,7 @@ class FormHelper extends AppHelper {
|
|
|
* - `value` The selected value of the input.
|
|
|
*
|
|
|
* @param string $fieldName Prefix name for the SELECT element
|
|
|
- * @param array|string $attributes Array of Attributes
|
|
|
+ * @param array $attributes Array of Attributes
|
|
|
* @return string Completed meridian select input
|
|
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::meridian
|
|
|
*/
|
|
|
@@ -2346,7 +2370,12 @@ class FormHelper extends AppHelper {
|
|
|
$attributes['value'] = date('a');
|
|
|
}
|
|
|
} else {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('a');
|
|
|
+ $Date = date_create($attributes['value']);
|
|
|
+ if ($Date) {
|
|
|
+ $attributes['value'] = $Date->format('a');
|
|
|
+ } else {
|
|
|
+ $attributes['value'] = null;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -2380,7 +2409,7 @@ class FormHelper extends AppHelper {
|
|
|
* @param string $fieldName Prefix name for the SELECT element
|
|
|
* @param string $dateFormat DMY, MDY, YMD, or null to not generate date inputs.
|
|
|
* @param string $timeFormat 12, 24, or null to not generate time inputs.
|
|
|
- * @param array|string $attributes array of Attributes
|
|
|
+ * @param array $attributes Array of Attributes
|
|
|
* @return string Generated set of select boxes for the date and time formats chosen.
|
|
|
* @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::dateTime
|
|
|
*/
|