Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix issue with array based values and interval.

Fixes #3299
  • Loading branch information...
commit c359e4b6890a3cfa979b413f4e1b63c80ccd96cc 1 parent e6512c5
@markstory markstory authored
View
9 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
@@ -2238,6 +2238,15 @@ public function testTimeSelectedWithInterval() {
$result = $this->Form->input('Model.start_time', array(
'type' => 'time',
'interval' => 15,
+ 'selected' => array('hour' => '3', 'min' => '57', 'meridian' => 'pm')
+ ));
+ $this->assertContains('<option value="04" selected="selected">4</option>', $result);
+ $this->assertContains('<option value="00" selected="selected">00</option>', $result);
+ $this->assertContains('<option value="pm" selected="selected">pm</option>', $result);
+
+ $result = $this->Form->input('Model.start_time', array(
+ 'type' => 'time',
+ 'interval' => 15,
'selected' => '2012-10-23 15:57:00'
));
$this->assertContains('<option value="04" selected="selected">4</option>', $result);
View
3  lib/Cake/View/Helper/FormHelper.php
@@ -2197,6 +2197,9 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a
if (!empty($attributes['value'])) {
if (is_array($attributes['value'])) {
extract($attributes['value']);
+ if ($meridian === 'pm') {
+ $hour += 12;
+ }
} else {
if (is_numeric($attributes['value'])) {
$attributes['value'] = strftime('%Y-%m-%d %H:%M:%S', $attributes['value']);
Please sign in to comment.
Something went wrong with that request. Please try again.