Skip to content
Permalink
Browse files

Fixing selected with interval not selecting the correct option. Fixes #…

  • Loading branch information...
markstory committed Sep 4, 2009
1 parent fb476f1 commit cf3521737f86d207458b58edb31ae62f022c5c29
Showing with 16 additions and 3 deletions.
  1. +4 −3 cake/libs/view/helpers/form.php
  2. +12 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -1610,15 +1610,16 @@ function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected
}
$opt = implode($separator, $selects);
}
if (!empty($interval) && $interval > 1 && !empty($min)) {
$min = round($min * (1 / $interval)) * $interval;
}
$selectMinuteAttr['interval'] = $interval;
switch ($timeFormat) {
case '24':
$selectMinuteAttr['interval'] = $interval;
$opt .= $this->hour($fieldName, true, $hour, $selectHourAttr, $showEmpty) . ':' .
$this->minute($fieldName, $min, $selectMinuteAttr, $showEmpty);
break;
case '12':
$selectMinuteAttr['interval'] = $interval;
$opt .= $this->hour($fieldName, false, $hour, $selectHourAttr, $showEmpty) . ':' .
$this->minute($fieldName, $min, $selectMinuteAttr, $showEmpty) . ' ' .
$this->meridian($fieldName, $meridian, $selectMeridianAttr, $showEmpty);
@@ -3675,6 +3675,18 @@ function testDateTime() {
':',
);
$this->assertTags($result, $expected);
$result = $this->Form->input('published', array(
'timeFormat' => 24,
'interval' => 5,
'selected' => strtotime('2009-09-03 13:37:00'),
'type' => 'datetime'
));
$this->assertPattern('/<option[^<>]+value="2009"[^<>]+selected="selected"[^>]*>2009<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="09"[^<>]+selected="selected"[^>]*>September<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="03"[^<>]+selected="selected"[^>]*>3<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="13"[^<>]+selected="selected"[^>]*>13<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="35"[^<>]+selected="selected"[^>]*>35<\/option>/', $result);
}
/**
* testFormDateTimeMulti method

0 comments on commit cf35217

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.