Fix issue with array based values and interval.

Fixes #3299
This commit is contained in:
mark_story 2012-10-25 20:46:54 -04:00
parent e6512c56fd
commit c359e4b689
2 changed files with 12 additions and 0 deletions

View file

@ -2235,6 +2235,15 @@ class FormHelperTest extends CakeTestCase {
* @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,

View file

@ -2197,6 +2197,9 @@ class FormHelper extends AppHelper {
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']);