[BUGFIX] Empty item group in selectElement 04/40204/3
authorajahn <a.jahn@immowelt.de>
Fri, 12 Jun 2015 08:42:37 +0000 (10:42 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Tue, 16 Jun 2015 10:51:48 +0000 (12:51 +0200)
Item groups that do not have any items are ignored and not rendered

Change-Id: I458a1491788fa8a78321a9c129949c08e62e375f
Resolves: #67394
Releases: master
Reviewed-on: http://review.typo3.org/40204
Tested-by: Pierrick Caillon <pierrick.caillon@plan-net.fr>
Reviewed-by: Alexander Jahn <jahn.typo3@googlemail.com>
Tested-by: Alexander Jahn <jahn.typo3@googlemail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php

index 5cd79d2..f44ecd2 100644 (file)
@@ -215,6 +215,11 @@ class SelectSingleElement extends AbstractFormElement {
 
                // Process groups
                foreach ($selectItemGroups as $selectItemGroup) {
+                       // suppress groups without items
+                       if (empty($selectItemGroup['items'])) {
+                               continue;
+                       }
+
                        $optionGroup = is_array($selectItemGroup['header']);
                        $options .= ($optionGroup ? '<optgroup label="' . htmlspecialchars($selectItemGroup['header']['title'], ENT_COMPAT, 'UTF-8', FALSE) . '">' : '');
                        if (is_array($selectItemGroup['items'])) {