[BUGFIX] Fix selected node count in select tree 42/43342/2
authorAlexander Stehlik <alexander.stehlik@gmail.com>
Tue, 15 Sep 2015 15:07:47 +0000 (17:07 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 15 Sep 2015 15:55:59 +0000 (17:55 +0200)
If only one item can be selected in a select tree field (maxitems=1)
and the first selected value is empty is will be cleared from the
selected node array.

Resolves: #69836
Releases: master
Change-Id: Ic3b71a39f73638a7d8c46c7939d17260356437dd
Reviewed-on: http://review.typo3.org/43342
Reviewed-by: Oliver Thiele <mail@oliver-thiele.de>
Tested-by: Oliver Thiele <mail@oliver-thiele.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php

index 75b42d2..0faca43 100644 (file)
@@ -45,9 +45,9 @@ class SelectTreeElement extends AbstractFormElement {
 
                $possibleSelectboxItems = $config['items'];
 
-               $selectedNodes = array();
-               if (!empty($parameterArray['itemFormElValue'])) {
-                       $selectedNodes = $parameterArray['itemFormElValue'];
+               $selectedNodes = $parameterArray['itemFormElValue'];
+               if ($config['maxitems'] === 1 && count($selectedNodes) === 1 && empty($selectedNodes[0])) {
+                       $selectedNodes = array();
                }
 
                $selectedNodesForApi = array();