Skip to content
This repository
Browse code

Fix issue with array based values and interval.

Fixes #3299
  • Loading branch information...
commit c359e4b6890a3cfa979b413f4e1b63c80ccd96cc 1 parent e6512c5
Mark Story authored
9  lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -2238,6 +2238,15 @@ public function testTimeSelectedWithInterval() {
2238 2238
 		$result = $this->Form->input('Model.start_time', array(
2239 2239
 			'type' => 'time',
2240 2240
 			'interval' => 15,
  2241
+			'selected' => array('hour' => '3', 'min' => '57', 'meridian' => 'pm')
  2242
+		));
  2243
+		$this->assertContains('<option value="04" selected="selected">4</option>', $result);
  2244
+		$this->assertContains('<option value="00" selected="selected">00</option>', $result);
  2245
+		$this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
  2246
+
  2247
+		$result = $this->Form->input('Model.start_time', array(
  2248
+			'type' => 'time',
  2249
+			'interval' => 15,
2241 2250
 			'selected' => '2012-10-23 15:57:00'
2242 2251
 		));
2243 2252
 		$this->assertContains('<option value="04" selected="selected">4</option>', $result);
3  lib/Cake/View/Helper/FormHelper.php
@@ -2197,6 +2197,9 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
2197 2197
 		if (!empty($attributes['value'])) {
2198 2198
 			if (is_array($attributes['value'])) {
2199 2199
 				extract($attributes['value']);
  2200
+				if ($meridian === 'pm') {
  2201
+					$hour += 12;
  2202
+				}
2200 2203
 			} else {
2201 2204
 				if (is_numeric($attributes['value'])) {
2202 2205
 					$attributes['value'] = strftime('%Y-%m-%d %H:%M:%S', $attributes['value']);

0 notes on commit c359e4b

Please sign in to comment.
Something went wrong with that request. Please try again.