mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fixing selected with interval not selecting the correct option. Fixes #70.
This commit is contained in:
parent
fb476f17cc
commit
cf3521737f
2 changed files with 16 additions and 3 deletions
|
@ -1610,15 +1610,16 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
$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 @@ class FormHelperTest extends CakeTestCase {
|
|||
':',
|
||||
);
|
||||
$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
|
||||
|
|
Loading…
Reference in a new issue