Permalink
Browse files

Fixed the input name when multiple is setted to false.

  • Loading branch information...
1 parent 54a4d24 commit 2c4ed9bfc28bb449aa37ffdf70fff1d42e453da5 @jrbasso jrbasso committed Apr 13, 2011
Showing with 21 additions and 1 deletion.
  1. +1 −1 cake/libs/view/helpers/form.php
  2. +20 −0 cake/tests/cases/libs/view/helpers/form.test.php
View
2 cake/libs/view/helpers/form.php
@@ -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];
View
20 cake/tests/cases/libs/view/helpers/form.test.php
@@ -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);
}
/**

0 comments on commit 2c4ed9b

Please sign in to comment.