Skip to content
This repository
Browse code

Fixed the input name when multiple is setted to false.

  • Loading branch information...
commit 2c4ed9bfc28bb449aa37ffdf70fff1d42e453da5 1 parent 54a4d24
Juan Basso authored April 13, 2011
2  cake/libs/view/helpers/form.php
@@ -1454,7 +1454,7 @@ function select($fieldName, $options = array(), $selected = null, $attributes =
1454 1454
 			$selected = $attributes['value'];
1455 1455
 		}
1456 1456
 
1457  
-		if (isset($attributes) && array_key_exists('multiple', $attributes)) {
  1457
+		if (!empty($attributes['multiple'])) {
1458 1458
 			$style = ($attributes['multiple'] === 'checkbox') ? 'checkbox' : null;
1459 1459
 			$template = ($style) ? 'checkboxmultiplestart' : 'selectmultiplestart';
1460 1460
 			$tag = $this->Html->tags[$template];
20  cake/tests/cases/libs/view/helpers/form.test.php
@@ -3360,6 +3360,26 @@ function testSelectMultiple() {
3360 3360
 			'/select'
3361 3361
 		);
3362 3362
 		$this->assertTags($result, $expected);
  3363
+
  3364
+		$result = $this->Form->select(
  3365
+			'Model.multi_field', $options, array(0, 1), array('multiple' => false)
  3366
+		);
  3367
+		$expected = array(
  3368
+			'select' => array(
  3369
+				'name' => 'data[Model][multi_field]', 'id' => 'ModelMultiField'
  3370
+			),
  3371
+			array('option' => array('value' => '0', 'selected' => 'selected')),
  3372
+			'first',
  3373
+			'/option',
  3374
+			array('option' => array('value' => '1', 'selected' => 'selected')),
  3375
+			'second',
  3376
+			'/option',
  3377
+			array('option' => array('value' => '2')),
  3378
+			'third',
  3379
+			'/option',
  3380
+			'/select'
  3381
+		);
  3382
+		$this->assertTags($result, $expected);
3363 3383
 	}
3364 3384
 
3365 3385
 /**

0 notes on commit 2c4ed9b

Please sign in to comment.
Something went wrong with that request. Please try again.