|
|
@@ -1492,7 +1492,7 @@ class FormHelper extends Helper {
|
|
|
public function postButton($title, $url, $options = array()) {
|
|
|
$out = $this->create(false, array('url' => $url));
|
|
|
if (isset($options['data']) && is_array($options['data'])) {
|
|
|
- foreach ($options['data'] as $key => $value) {
|
|
|
+ foreach (Hash::flatten($options['data']) as $key => $value) {
|
|
|
$out .= $this->hidden($key, array('value' => $value));
|
|
|
}
|
|
|
unset($options['data']);
|
|
|
@@ -1566,7 +1566,7 @@ class FormHelper extends Helper {
|
|
|
|
|
|
$fields = array();
|
|
|
if (isset($options['data']) && is_array($options['data'])) {
|
|
|
- foreach ($options['data'] as $key => $value) {
|
|
|
+ foreach (Hash::flatten($options['data']) as $key => $value) {
|
|
|
$fields[$key] = $value;
|
|
|
$out .= $this->hidden($key, array('value' => $value));
|
|
|
}
|
|
|
@@ -1855,7 +1855,11 @@ class FormHelper extends Helper {
|
|
|
$attributes = $this->_dateTimeSelected('day', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('d');
|
|
|
+ $date = date_create($attributes['value']);
|
|
|
+ $attributes['value'] = null;
|
|
|
+ if ($date) {
|
|
|
+ $attributes['value'] = $date->format('d');
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -1902,7 +1906,11 @@ class FormHelper extends Helper {
|
|
|
}
|
|
|
|
|
|
if (strlen($attributes['value']) > 4 || $attributes['value'] === 'now') {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('Y');
|
|
|
+ $date = date_create($attributes['value']);
|
|
|
+ $attributes['value'] = null;
|
|
|
+ if ($date) {
|
|
|
+ $attributes['value'] = $date->format('Y');
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -1938,7 +1946,11 @@ class FormHelper extends Helper {
|
|
|
$attributes = $this->_dateTimeSelected('month', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('m');
|
|
|
+ $date = date_create($attributes['value']);
|
|
|
+ $attributes['value'] = null;
|
|
|
+ if ($date) {
|
|
|
+ $attributes['value'] = $date->format('m');
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -1974,11 +1986,15 @@ class FormHelper extends Helper {
|
|
|
$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;
|
|
|
@@ -2017,7 +2033,11 @@ class FormHelper extends Helper {
|
|
|
$attributes = $this->_dateTimeSelected('min', $fieldName, $attributes);
|
|
|
|
|
|
if (strlen($attributes['value']) > 2) {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('i');
|
|
|
+ $date = date_create($attributes['value']);
|
|
|
+ $attributes['value'] = null;
|
|
|
+ if ($date) {
|
|
|
+ $attributes['value'] = $date->format('i');
|
|
|
+ }
|
|
|
} elseif ($attributes['value'] === false) {
|
|
|
$attributes['value'] = null;
|
|
|
}
|
|
|
@@ -2068,7 +2088,7 @@ class FormHelper extends Helper {
|
|
|
* - `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
|
|
|
*/
|
|
|
@@ -2085,7 +2105,11 @@ class FormHelper extends Helper {
|
|
|
$attributes['value'] = date('a');
|
|
|
}
|
|
|
} else {
|
|
|
- $attributes['value'] = date_create($attributes['value'])->format('a');
|
|
|
+ $date = date_create($attributes['value']);
|
|
|
+ $attributes['value'] = null;
|
|
|
+ if ($date) {
|
|
|
+ $attributes['value'] = $date->format('a');
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|