From a29d77179795eac3bba204cfdc38f9086a9315a5 Mon Sep 17 00:00:00 2001
From: Christian Kuhn <lolli@schwarzbu.ch>
Date: Sat, 28 May 2016 22:52:56 +0200
Subject: [PATCH] [BUGFIX] FormEngine: Inline records open after first save

After creating and saving new inline elements, those elements
should be open by default. This was the case earlier, but broke
somewhere during FormEngine refactoring.

The patch restores this functionality. However, this patch is
restricted for master only since various scenarios are possible
that lead to funny open/close state. Those need further work.

Change-Id: I3b7dd6ebb5141f00317ef508b94ac41f4d44d265
Resolves: #76360
Releases: master
Reviewed-on: https://review.typo3.org/48378
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Markus Klein <markus.klein@typo3.org>
Tested-by: Markus Klein <markus.klein@typo3.org>
---
 .../backend/Classes/Controller/FormInlineAjaxController.php  | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php
index 3c2b4c0ca59d..f2a1edce1f99 100644
--- a/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php
+++ b/typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php
@@ -56,6 +56,7 @@ class FormInlineAjaxController
         $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
         $inlineStackProcessor->initializeByParsingDomObjectIdString($domObjectId);
         $inlineStackProcessor->injectAjaxConfiguration($ajaxArguments['context']);
+        $inlineTopMostParent = $inlineStackProcessor->getStructureLevel(0);
 
         // Parent, this table embeds the child table
         $parent = $inlineStackProcessor->getStructureLevel(-1);
@@ -125,6 +126,10 @@ class FormInlineAjaxController
             'inlineParentTableName' => $parent['table'],
             'inlineParentFieldName' => $parent['field'],
             'inlineParentConfig' => $parentConfig,
+            // Fallback to $parentData is probably not needed here.
+            'inlineTopMostParentUid' => $parentData['inlineTopMostParentUid'] ?: $inlineTopMostParent['uid'],
+            'inlineTopMostParentTableName' => $parentData['inlineTopMostParentTableName'] ?: $inlineTopMostParent['table'],
+            'inlineTopMostParentFieldName' => $parentData['inlineTopMostParentFieldName'] ?: $inlineTopMostParent['field'],
         ];
         if ($childChildUid) {
             $formDataCompilerInput['inlineChildChildUid'] = $childChildUid;
-- 
GitLab