Fixed the input name when multiple is setted to false.

This commit is contained in:
Juan Basso 2011-04-13 00:32:15 -04:00
parent 54a4d24a03
commit 2c4ed9bfc2
2 changed files with 21 additions and 1 deletions

View file

@ -1454,7 +1454,7 @@ class FormHelper extends AppHelper {
$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];

View file

@ -3360,6 +3360,26 @@ class FormHelperTest extends CakeTestCase {
'/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);
}
/**