Skip to content

Commit

Permalink
Fix for HTML attributes being ignored for individual datetime selects.
Browse files Browse the repository at this point in the history
Closes #5829
  • Loading branch information
ADmad committed Feb 8, 2015
1 parent ed5b3de commit 40a6634
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/View/Helper/FormHelper.php
Expand Up @@ -1884,7 +1884,12 @@ protected function _singleDatetime($options, $keep)
$off,
array_fill(0, count($off), false)
);
$options = $off + $options;

$attributes = array_diff_key(
$options,
['value' => null, 'empty' => null]
);
$options = $options + $off + [$keep => $attributes];

if (isset($options['value'])) {
$options['val'] = $options['value'];
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -5194,9 +5194,9 @@ public function testDay()
{
extract($this->dateRegex);

$result = $this->Form->day('Model.field', ['value' => '']);
$result = $this->Form->day('Model.field', ['value' => '', 'class' => 'form-control']);
$expected = [
['select' => ['name' => 'Model[field][day]']],
['select' => ['name' => 'Model[field][day]', 'class' => 'form-control']],
['option' => ['selected' => 'selected', 'value' => '']],
'/option',
['option' => ['value' => '01']],
Expand Down

0 comments on commit 40a6634

Please sign in to comment.