Skip to content

Commit

Permalink
Fix empty options not being set for single datetime inputs.
Browse files Browse the repository at this point in the history
String and boolean values should be propagated into the component
pickers.

Refs #5818
  • Loading branch information
markstory committed Feb 3, 2015
1 parent 4c9d704 commit 11719e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/View/Helper/FormHelper.php
Expand Up @@ -2143,9 +2143,8 @@ protected function _datetimeOptions($options)
$options[$type] = [];
}

// Pass empty boolean to each type.
// Pass empty options to each type.
if (!empty($options['empty']) &&
is_bool($options['empty']) &&
is_array($options[$type])
) {
$options[$type]['empty'] = $options['empty'];
Expand Down
15 changes: 15 additions & 0 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -5178,6 +5178,11 @@ public function testMonth()
'*/select',
];
$this->assertHtml($expected, $result);

$result = $this->Form->month('Contact.published', [
'empty' => 'Published on',
]);
$this->assertContains('Published on', $result);
}

/**
Expand Down Expand Up @@ -5268,6 +5273,11 @@ public function testDay()
'/select',
];
$this->assertHtml($expected, $result);

$result = $this->Form->day('Contact.published', [
'empty' => 'Published on',
]);
$this->assertContains('Published on', $result);
}

/**
Expand Down Expand Up @@ -5545,6 +5555,11 @@ public function testYear()
'/select',
];
$this->assertHtml($expected, $result);

$result = $this->Form->year('Contact.published', [
'empty' => 'Published on',
]);
$this->assertContains('Published on', $result);
}

/**
Expand Down

0 comments on commit 11719e9

Please sign in to comment.