From 72471b2102ae2f97d6de1dbcf3c756b70a2316f7 Mon Sep 17 00:00:00 2001
From: Garvin Hicking <gh@faktor-e.de>
Date: Tue, 25 Jun 2024 12:35:32 +0200
Subject: [PATCH] [BUGFIX] Fix invalid FormEngine HTML structure on edge-case
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When the TCA type "group" is rendered in FormEngine, under
certain circumstances the HTML structure would close add
`<div>` elements without opening those first. This will
lead to a record not being editable, because variables are
wrongly transferred due to the browser-rendering of wrong
HTML nesting levels.

This behaviour is an edge case and only happens with this TCA
configuration:

* either `config[hideMoveIcons]` is set to `true`
* or `config[hideDeleteIcon]` is set to `true`

Resolves: #98436
Releases: main, 12.4, 11.5
Change-Id: Ibb28c6130051b3dae92b3285df0831e84634e210
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/85012
Tested-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: core-ci <typo3@b13.com>
---
 typo3/sysext/backend/Classes/Form/Element/GroupElement.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
index 8b723a44b071..9e64c3f1b30b 100644
--- a/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
+++ b/typo3/sysext/backend/Classes/Form/Element/GroupElement.php
@@ -348,9 +348,9 @@ class GroupElement extends AbstractFormElement
                 $html[] =               $this->iconFactory->getIcon('actions-selection-delete', Icon::SIZE_SMALL)->render();
                 $html[] =           '</a>';
             }
+            $html[] =           '</div>';
+            $html[] =       '</div>';
         }
-        $html[] =           '</div>';
-        $html[] =       '</div>';
         if ($fieldControlHtml !== '') {
             $html[] =       '<div class="form-wizards-items-aside form-wizards-items-aside--field-control">';
             $html[] =           '<div class="btn-group-vertical">';
-- 
GitLab