Browse Source

Fix multiple=false being ignored in multi-select inputs.

Merge branch 'issue-11771' into master.
mark_story 8 years ago
parent
commit
caa7d66f12
2 changed files with 8 additions and 1 deletions
  1. 1 1
      src/View/Helper/FormHelper.php
  2. 7 0
      tests/TestCase/View/Helper/FormHelperTest.php

+ 1 - 1
src/View/Helper/FormHelper.php

@@ -1405,7 +1405,7 @@ class FormHelper extends Helper
 
         if ($allowOverride && substr($fieldName, -5) === '._ids') {
             $options['type'] = 'select';
-            if (empty($options['multiple'])) {
+            if ((!isset($options['multiple']) || ($options['multiple'] && $options['multiple'] != 'checkbox'))) {
                 $options['multiple'] = true;
             }
         }

+ 7 - 0
tests/TestCase/View/Helper/FormHelperTest.php

@@ -5194,6 +5194,13 @@ class FormHelperTest extends TestCase
             ['multiple' => 'multiple', 'form' => 'my-form']
         );
         $this->assertHtml($expected, $result);
+
+        $result = $this->Form->select(
+            'Model.multi_field',
+            $options,
+            ['form' => 'my-form', 'multiple' => false]
+        );
+        $this->assertNotContains('multiple', $result);
     }
 
     /**