[TASK] Render wizards of FormEngine elements only if needed 14/57614/3
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 17 Jul 2018 02:23:54 +0000 (04:23 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Sat, 11 Aug 2018 20:08:47 +0000 (22:08 +0200)
Reduce the HTML of a record form by rendering divs of wizards only
if those are required.

Resolves: #85577
Releases: master
Change-Id: I6ca6ad5c3ebd1a1aa949a9a0349bd7894e4532df
Reviewed-on: https://review.typo3.org/57614
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
20 files changed:
typo3/sysext/backend/Classes/Form/Element/CheckboxElement.php
typo3/sysext/backend/Classes/Form/Element/CheckboxLabeledToggleElement.php
typo3/sysext/backend/Classes/Form/Element/CheckboxToggleElement.php
typo3/sysext/backend/Classes/Form/Element/GroupElement.php
typo3/sysext/backend/Classes/Form/Element/InputColorPickerElement.php
typo3/sysext/backend/Classes/Form/Element/InputDateTimeElement.php
typo3/sysext/backend/Classes/Form/Element/InputLinkElement.php
typo3/sysext/backend/Classes/Form/Element/InputTextElement.php
typo3/sysext/backend/Classes/Form/Element/RadioElement.php
typo3/sysext/backend/Classes/Form/Element/SelectCheckBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectMultipleSideBySideElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleBoxElement.php
typo3/sysext/backend/Classes/Form/Element/SelectSingleElement.php
typo3/sysext/backend/Classes/Form/Element/SelectTreeElement.php
typo3/sysext/backend/Classes/Form/Element/TextElement.php
typo3/sysext/backend/Classes/Form/Element/TextTableElement.php
typo3/sysext/backend/Classes/View/Wizard/Element/BackendLayoutWizardElement.php
typo3/sysext/rsaauth/Classes/Form/Element/RsaInputElement.php
typo3/sysext/rte_ckeditor/Classes/Form/Element/RichTextElement.php
typo3/sysext/t3editor/Classes/Form/Element/T3editorElement.php

index 0f4cda8..ff81cd8 100644 (file)
@@ -146,7 +146,7 @@ class CheckboxElement extends AbstractFormElement
         $html[] =       '<div class="form-wizards-element">';
         $html[] =           $elementHtml;
         $html[] =       '</div>';
-        if (!$disabled) {
+        if (!$disabled && !empty($fieldWizardHtml)) {
             $html[] =   '<div class="form-wizards-items-bottom">';
             $html[] =       $fieldWizardHtml;
             $html[] =   '</div>';
index adfba81..743ea24 100644 (file)
@@ -145,7 +145,7 @@ class CheckboxLabeledToggleElement extends AbstractFormElement
         $html[] =       '<div class="form-wizards-element">';
         $html[] =           $elementHtml;
         $html[] =       '</div>';
-        if (!$disabled) {
+        if (!$disabled && !empty($fieldWizardHtml)) {
             $html[] =   '<div class="form-wizards-items-bottom">';
             $html[] =       $fieldWizardHtml;
             $html[] =   '</div>';
index f3a63dc..e94cf94 100644 (file)
@@ -145,7 +145,7 @@ class CheckboxToggleElement extends AbstractFormElement
         $html[] =       '<div class="form-wizards-element">';
         $html[] =           $elementHtml;
         $html[] =       '</div>';
-        if (!$disabled) {
+        if (!$disabled && !empty($fieldWizardHtml)) {
             $html[] =   '<div class="form-wizards-items-bottom">';
             $html[] =       $fieldWizardHtml;
             $html[] =   '</div>';
index a425f6e..eaf793a 100644 (file)
@@ -400,9 +400,11 @@ class GroupElement extends AbstractFormElement
         $html[] =               $fieldControlHtml;
         $html[] =           '</div>';
         $html[] =       '</div>';
-        $html[] =       '<div class="form-wizards-items-bottom">';
-        $html[] =           $fieldWizardHtml;
-        $html[] =       '</div>';
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =   '</div>';
         $html[] =   '<input type="hidden" name="' . htmlspecialchars($elementName) . '" value="' . htmlspecialchars(implode(',', $listOfSelectedValues)) . '" />';
         $html[] = '</div>';
index 1aaee25..aa1ab26 100644 (file)
@@ -186,9 +186,11 @@ class InputColorPickerElement extends AbstractFormElement
         $mainFieldHtml[] =              implode(LF, $valuePickerHtml);
         $mainFieldHtml[] =          '</div>';
         $mainFieldHtml[] =      '</div>';
-        $mainFieldHtml[] =      '<div class="form-wizards-items-bottom">';
-        $mainFieldHtml[] =          $fieldWizardHtml;
-        $mainFieldHtml[] =      '</div>';
+        if (!empty($fieldWizardHtml)) {
+            $mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
+            $mainFieldHtml[] = $fieldWizardHtml;
+            $mainFieldHtml[] = '</div>';
+        }
         $mainFieldHtml[] =  '</div>';
         $mainFieldHtml[] = '</div>';
         $mainFieldHtml = implode(LF, $mainFieldHtml);
index d8ed303..a777d9a 100644 (file)
@@ -198,14 +198,18 @@ class InputDateTimeElement extends AbstractFormElement
         $expansionHtml[] =              '</span>';
         $expansionHtml[] =          '</div>';
         $expansionHtml[] =      '</div>';
-        $expansionHtml[] =      '<div class="form-wizards-items-aside">';
-        $expansionHtml[] =          '<div class="btn-group">';
-        $expansionHtml[] =              $fieldControlHtml;
-        $expansionHtml[] =          '</div>';
-        $expansionHtml[] =      '</div>';
-        $expansionHtml[] =      '<div class="form-wizards-items-bottom">';
-        $expansionHtml[] =          $fieldWizardHtml;
-        $expansionHtml[] =      '</div>';
+        if (!empty($fieldControlHtml)) {
+            $expansionHtml[] =      '<div class="form-wizards-items-aside">';
+            $expansionHtml[] =          '<div class="btn-group">';
+            $expansionHtml[] =              $fieldControlHtml;
+            $expansionHtml[] =          '</div>';
+            $expansionHtml[] =      '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $expansionHtml[] = '<div class="form-wizards-items-bottom">';
+            $expansionHtml[] = $fieldWizardHtml;
+            $expansionHtml[] = '</div>';
+        }
         $expansionHtml[] =  '</div>';
         $expansionHtml[] = '</div>';
         $expansionHtml = implode(LF, $expansionHtml);
index d47f477..fc72595 100644 (file)
@@ -230,12 +230,14 @@ class InputLinkElement extends AbstractFormElement
         $expansionHtml[] =              '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($itemValue) . '" />';
         $expansionHtml[] =          '</div>';
         $expansionHtml[] =      '</div>';
-        $expansionHtml[] =      '<div class="form-wizards-items-aside">';
-        $expansionHtml[] =          '<div class="btn-group">';
-        $expansionHtml[] =              implode(LF, $valuePickerHtml);
-        $expansionHtml[] =              $fieldControlHtml;
-        $expansionHtml[] =          '</div>';
-        $expansionHtml[] =      '</div>';
+        if (!empty($valuePickerHtml) || !empty($fieldControlHtml)) {
+            $expansionHtml[] =      '<div class="form-wizards-items-aside">';
+            $expansionHtml[] =          '<div class="btn-group">';
+            $expansionHtml[] =              implode(LF, $valuePickerHtml);
+            $expansionHtml[] =              $fieldControlHtml;
+            $expansionHtml[] =          '</div>';
+            $expansionHtml[] =      '</div>';
+        }
         $expansionHtml[] =      '<div class="form-wizards-items-bottom">';
         $expansionHtml[] =          $linkExplanation['additionalAttributes'];
         $expansionHtml[] =          $fieldWizardHtml;
index 42baeda..2fdc92b 100644 (file)
@@ -244,16 +244,20 @@ class InputTextElement extends AbstractFormElement
         $mainFieldHtml[] =          '<input type="' . $inputType . '"' . GeneralUtility::implodeAttributes($attributes, true) . ' />';
         $mainFieldHtml[] =          '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($itemValue) . '" />';
         $mainFieldHtml[] =      '</div>';
-        $mainFieldHtml[] =      '<div class="form-wizards-items-aside">';
-        $mainFieldHtml[] =          '<div class="btn-group">';
-        $mainFieldHtml[] =              implode(LF, $valuePickerHtml);
-        $mainFieldHtml[] =              implode(LF, $valueSliderHtml);
-        $mainFieldHtml[] =              $fieldControlHtml;
-        $mainFieldHtml[] =          '</div>';
-        $mainFieldHtml[] =      '</div>';
-        $mainFieldHtml[] =      '<div class="form-wizards-items-bottom">';
-        $mainFieldHtml[] =          $fieldWizardHtml;
-        $mainFieldHtml[] =      '</div>';
+        if (!empty($valuePickerHtml) || !empty($valueSliderHtml) || !empty($fieldControlHtml)) {
+            $mainFieldHtml[] =      '<div class="form-wizards-items-aside">';
+            $mainFieldHtml[] =          '<div class="btn-group">';
+            $mainFieldHtml[] =              implode(LF, $valuePickerHtml);
+            $mainFieldHtml[] =              implode(LF, $valueSliderHtml);
+            $mainFieldHtml[] =              $fieldControlHtml;
+            $mainFieldHtml[] =          '</div>';
+            $mainFieldHtml[] =      '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
+            $mainFieldHtml[] = $fieldWizardHtml;
+            $mainFieldHtml[] = '</div>';
+        }
         $mainFieldHtml[] =  '</div>';
         $mainFieldHtml[] = '</div>';
         $mainFieldHtml = implode(LF, $mainFieldHtml);
index 1da7c55..d8b6414 100644 (file)
@@ -101,7 +101,7 @@ class RadioElement extends AbstractFormElement
             $html[] =     '</label>';
             $html[] = '</div>';
         }
-        if (!$disabled) {
+        if (!$disabled && !empty($fieldWizardHtml)) {
             $html[] =   '<div class="form-wizards-items-bottom">';
             $html[] =       $fieldWizardHtml;
             $html[] =   '</div>';
index 63a39ff..7b7ac43 100644 (file)
@@ -242,7 +242,7 @@ class SelectCheckBoxElement extends AbstractFormElement
             }
 
             $html[] =       '</div>';
-            if (!$disabled) {
+            if (!$disabled && !empty($fieldWizardHtml)) {
                 $html[] =   '<div class="form-wizards-items-bottom">';
                 $html[] =       $fieldWizardHtml;
                 $html[] =   '</div>';
index ba9ee4a..c1aa368 100644 (file)
@@ -307,19 +307,23 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
         $html[] =                               implode(LF, $selectableItemsHtml);
         $html[] =                           '</select>';
         $html[] =                       '</div>';
-        $html[] =                       '<div class="form-wizards-items-aside">';
-        $html[] =                           '<div class="btn-group-vertical">';
-        $html[] =                               $fieldControlHtml;
-        $html[] =                           '</div>';
-        $html[] =                       '</div>';
+        if (!empty($fieldControlHtml)) {
+            $html[] =                       '<div class="form-wizards-items-aside">';
+            $html[] =                           '<div class="btn-group-vertical">';
+            $html[] =                               $fieldControlHtml;
+            $html[] =                           '</div>';
+            $html[] =                       '</div>';
+        }
         $html[] =                   '</div>';
         $html[] =               '</div>';
         $html[] =           '</div>';
         $html[] =           '<input type="hidden" name="' . htmlspecialchars($elementName) . '" value="' . htmlspecialchars(implode(',', $listOfSelectedValues)) . '" />';
         $html[] =       '</div>';
-        $html[] =       '<div class="form-wizards-items-bottom">';
-        $html[] =           $fieldWizardHtml;
-        $html[] =       '</div>';
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =   '</div>';
         $html[] = '</div>';
 
index eacd0a6..045a05b 100644 (file)
@@ -134,17 +134,20 @@ class SelectSingleBoxElement extends AbstractFormElement
         $html[] =               $selectElement;
         $html[] =           '</div>';
         if (!$disabled) {
-            $html[] =       '<div class="form-wizards-items-aside">';
-            $html[] =           $fieldControlHtml;
-            $html[] =       '</div>';
-            $html[] =   '</div>';
-
+            if (!empty($fieldControlHtml)) {
+                $html[] =       '<div class="form-wizards-items-aside">';
+                $html[] =           $fieldControlHtml;
+                $html[] =       '</div>';
+                $html[] =   '</div>';
+            }
             $html[] =   '<p>';
             $html[] =       '<em>' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.holdDownCTRL')) . '</em>';
             $html[] =   '</p>';
-            $html[] =   '<div class="form-wizards-items-bottom">';
-            $html[] =       $fieldWizardHtml;
-            $html[] =   '</div>';
+            if (!empty($fieldWizardHtml)) {
+                $html[] = '<div class="form-wizards-items-bottom">';
+                $html[] = $fieldWizardHtml;
+                $html[] = '</div>';
+            }
         }
         $html[] =   '</div>';
         $html[] = '</div>';
index 265afe1..f97927d 100644 (file)
@@ -228,7 +228,7 @@ class SelectSingleElement extends AbstractFormElement
             $html[] =           '</div>';
         }
         $html[] =           '</div>';
-        if (!$disabled) {
+        if (!$disabled && !empty($fieldWizardHtml)) {
             $html[] =       '<div class="form-wizards-items-bottom">';
             $html[] =           $fieldWizardHtml;
             $html[] =       '</div>';
index 079b0db..7941fd4 100644 (file)
@@ -167,7 +167,7 @@ class SelectTreeElement extends AbstractFormElement
         $html[] =               '<div id="' . $treeWrapperId . '" class="svg-tree-wrapper" style="height: ' . $heightInPx . 'px;"></div>';
         $html[] =               '<script type="text/javascript">var ' . $treeWrapperId . ' = ' . $this->getTreeOnChangeJs() . '</script>';
         $html[] =           '</div>';
-        if ($readOnly === 'false') {
+        if ($readOnly === 'false' && !empty($fieldWizardHtml)) {
             $html[] =       '<div class="form-wizards-items-bottom">';
             $html[] =           $fieldWizardHtml;
             $html[] =       '</div>';
index ccf588a..13a08cd 100644 (file)
@@ -219,15 +219,19 @@ class TextElement extends AbstractFormElement
         $mainFieldHtml[] =      '<div class="form-wizards-element">';
         $mainFieldHtml[] =          '<textarea ' . GeneralUtility::implodeAttributes($attributes, true) . '>' . htmlspecialchars($itemValue) . '</textarea>';
         $mainFieldHtml[] =      '</div>';
-        $mainFieldHtml[] =      '<div class="form-wizards-items-aside">';
-        $mainFieldHtml[] =          '<div class="btn-group">';
-        $mainFieldHtml[] =              implode(LF, $valuePickerHtml);
-        $mainFieldHtml[] =              $fieldControlHtml;
-        $mainFieldHtml[] =          '</div>';
-        $mainFieldHtml[] =      '</div>';
-        $mainFieldHtml[] =      '<div class="form-wizards-items-bottom">';
-        $mainFieldHtml[] =          $fieldWizardHtml;
-        $mainFieldHtml[] =      '</div>';
+        if (!empty($valuePickerHtml) || !empty($fieldControlHtml)) {
+            $mainFieldHtml[] =      '<div class="form-wizards-items-aside">';
+            $mainFieldHtml[] =          '<div class="btn-group">';
+            $mainFieldHtml[] =              implode(LF, $valuePickerHtml);
+            $mainFieldHtml[] =              $fieldControlHtml;
+            $mainFieldHtml[] =          '</div>';
+            $mainFieldHtml[] =      '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
+            $mainFieldHtml[] = $fieldWizardHtml;
+            $mainFieldHtml[] = '</div>';
+        }
         $mainFieldHtml[] =  '</div>';
         $mainFieldHtml[] = '</div>';
         $mainFieldHtml = implode(LF, $mainFieldHtml);
index e49a3e2..446807b 100644 (file)
@@ -200,14 +200,18 @@ class TextTableElement extends AbstractFormElement
         $html[] =           '<div class="form-wizards-element">';
         $html[] =               '<textarea ' . GeneralUtility::implodeAttributes($attributes, true) . '>' . htmlspecialchars($itemValue) . '</textarea>';
         $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-aside">';
-        $html[] =               '<div class="btn-group">';
-        $html[] =                   $fieldControlHtml;
-        $html[] =               '</div>';
-        $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-bottom">';
-        $html[] =               $fieldWizardHtml;
-        $html[] =           '</div>';
+        if (!empty($fieldControlHtml)) {
+            $html[] =           '<div class="form-wizards-items-aside">';
+            $html[] =               '<div class="btn-group">';
+            $html[] =                   $fieldControlHtml;
+            $html[] =               '</div>';
+            $html[] =           '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =       '</div>';
         $html[] =   '</div>';
         $html[] = '</div>';
index fd87d40..aaf3ff2 100644 (file)
@@ -129,9 +129,11 @@ class BackendLayoutWizardElement extends AbstractFormElement
         $html[] =                   '</tr>';
         $html[] =               '</table>';
         $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-bottom">';
-        $html[] =               $fieldWizardHtml;
-        $html[] =           '</div>';
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =       '</div>';
         $html[] =   '</div>';
         $html[] = '</div>';
index 18b380c..a213127 100644 (file)
@@ -176,14 +176,18 @@ class RsaInputElement extends AbstractFormElement
         $html[] =                   ' value="' . htmlspecialchars($itemValue) . '"';
         $html[] =               '/>';
         $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-aside">';
-        $html[] =               '<div class="btn-group">';
-        $html[] =                   $fieldControlHtml;
-        $html[] =               '</div>';
-        $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-bottom">';
-        $html[] =               $fieldWizardHtml;
-        $html[] =           '</div>';
+        if (!empty($fieldControlHtml)) {
+            $html[] =           '<div class="form-wizards-items-aside">';
+            $html[] =               '<div class="btn-group">';
+            $html[] =                   $fieldControlHtml;
+            $html[] =               '</div>';
+            $html[] =           '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =       '</div>';
         $html[] =   '</div>';
         $html[] = '</div>';
index aa8dc95..8e3bc6c 100644 (file)
@@ -115,14 +115,18 @@ class RichTextElement extends AbstractFormElement
         $html[] =                   htmlspecialchars($value);
         $html[] =               '</textarea>';
         $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-aside">';
-        $html[] =               '<div class="btn-group">';
-        $html[] =                   $fieldControlHtml;
-        $html[] =               '</div>';
-        $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-bottom">';
-        $html[] =               $fieldWizardHtml;
-        $html[] =           '</div>';
+        if (!empty($fieldControlHtml)) {
+            $html[] =           '<div class="form-wizards-items-aside">';
+            $html[] =               '<div class="btn-group">';
+            $html[] =                   $fieldControlHtml;
+            $html[] =               '</div>';
+            $html[] =           '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =       '</div>';
         $html[] =   '</div>';
         $html[] = '</div>';
index 600f299..8ac16a8 100644 (file)
@@ -159,14 +159,18 @@ class T3editorElement extends AbstractFormElement
         $html[] =           '<div class="form-wizards-element">';
         $html[] =               $editorHtml;
         $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-aside">';
-        $html[] =               '<div class="btn-group">';
-        $html[] =                   $fieldControlHtml;
-        $html[] =               '</div>';
-        $html[] =           '</div>';
-        $html[] =           '<div class="form-wizards-items-bottom">';
-        $html[] =               $fieldWizardHtml;
-        $html[] =           '</div>';
+        if (!empty($fieldControlHtml)) {
+            $html[] =           '<div class="form-wizards-items-aside">';
+            $html[] =               '<div class="btn-group">';
+            $html[] =                   $fieldControlHtml;
+            $html[] =               '</div>';
+            $html[] =           '</div>';
+        }
+        if (!empty($fieldWizardHtml)) {
+            $html[] = '<div class="form-wizards-items-bottom">';
+            $html[] = $fieldWizardHtml;
+            $html[] = '</div>';
+        }
         $html[] =       '</div>';
         $html[] =   '</div>';
         $html[] = '</div>';