[BUGFIX] FormEngine: Size equals to 1 if none set on multi-selects 29/27829/7
authorDaniel Maier <dani-maier@gmx.de>
Wed, 17 Jun 2015 10:36:03 +0000 (12:36 +0200)
committerBenjamin Mack <benni@typo3.org>
Wed, 17 Jun 2015 15:08:02 +0000 (17:08 +0200)
Having a FormEngine select element with maxitems=10
and no size set, then a typical single-select element
is rendered, with no chance of using the up- and
down buttons provided, as the single select does not
allow to use more than one entry in rendering.

The browser behavior is not adopted and if size
is not given, a broken state is rendered.

Releases: master
Resolves: #56259
Change-Id: I9963503cb046353b81f13b0c624bddbd7e5b74f8
Reviewed-on: http://review.typo3.org/27829
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Jan Helke <typo3@helke.de>
Tested-by: Jan Helke <typo3@helke.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php

index e7f3fa2..32815e9 100644 (file)
@@ -156,10 +156,18 @@ class SelectMultipleSideBySideElement extends AbstractFormElement {
                        }
                        $itemArray[$tk] = implode('|', $tvP);
                }
+
+               // size must be at least two, as there are always maxitems > 1 (see parent function)
+               if (isset($config['size'])) {
+                       $size = (int)$config['size'];
+               } else {
+                       $size = 2;
+               }
+               $size = $config['autoSizeMax'] ? MathUtility::forceIntegerInRange(count($itemArray) + 1, MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax']) : $size;
+
                $itemsToSelect = '';
                $filterTextfield = '';
                $filterSelectbox = '';
-               $size = 0;
                if (!$disabled) {
                        // Create option tags:
                        $opt = array();
@@ -176,10 +184,6 @@ class SelectMultipleSideBySideElement extends AbstractFormElement {
                        $selector_itemListStyle = isset($config['itemListStyle'])
                                ? ' style="' . htmlspecialchars($config['itemListStyle']) . '"'
                                : '';
-                       $size = (int)$config['size'];
-                       $size = $config['autoSizeMax']
-                               ? MathUtility::forceIntegerInRange(count($itemArray) + 1, MathUtility::forceIntegerInRange($size, 1), $config['autoSizeMax'])
-                               : $size;
                        $sOnChange = implode('', $parameterArray['fieldChangeFunc']);
 
                        $multiSelectId = str_replace('.', '', uniqid('tceforms-multiselect-', TRUE));