Skip to content

Commit

Permalink
Fixed the input name when multiple is setted to false.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Apr 13, 2011
1 parent 54a4d24 commit 2c4ed9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/form.php
Expand Up @@ -1454,7 +1454,7 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
$selected = $attributes['value'];
}

if (isset($attributes) && array_key_exists('multiple', $attributes)) {
if (!empty($attributes['multiple'])) {
$style = ($attributes['multiple'] === 'checkbox') ? 'checkbox' : null;
$template = ($style) ? 'checkboxmultiplestart' : 'selectmultiplestart';
$tag = $this->Html->tags[$template];
Expand Down
20 changes: 20 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -3360,6 +3360,26 @@ function testSelectMultiple() {
'/select'
);
$this->assertTags($result, $expected);

$result = $this->Form->select(
'Model.multi_field', $options, array(0, 1), array('multiple' => false)
);
$expected = array(
'select' => array(
'name' => 'data[Model][multi_field]', 'id' => 'ModelMultiField'
),
array('option' => array('value' => '0', 'selected' => 'selected')),
'first',
'/option',
array('option' => array('value' => '1', 'selected' => 'selected')),
'second',
'/option',
array('option' => array('value' => '2')),
'third',
'/option',
'/select'
);
$this->assertTags($result, $expected);
}

/**
Expand Down

0 comments on commit 2c4ed9b

Please sign in to comment.