Skip to content

Commit

Permalink
Fix issue with array based values and interval.
Browse files Browse the repository at this point in the history
Fixes #3299
  • Loading branch information
markstory committed Oct 26, 2012
1 parent e6512c5 commit c359e4b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -2235,6 +2235,15 @@ public function testInputTime() {
* @return void
*/
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,
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -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']);
Expand Down

0 comments on commit c359e4b

Please sign in to comment.