uc and put it into $result['inlineExpandCollapseStateArray'] */ class TcaInlineExpandCollapseState implements FormDataProviderInterface { /** * Add inline expand / collapse state * * @return array */ public function addData(array $result) { if (empty($result['inlineExpandCollapseStateArray'])) { $fullInlineState = json_decode($this->getBackendUser()->uc['inlineView'] ?? '', true); if (!is_array($fullInlineState)) { $fullInlineState = []; } $inlineStateForTable = []; if (!empty($result['inlineTopMostParentUid']) && !empty($result['inlineTopMostParentTableName'])) { // Happens in inline ajax context, top parent uid and top parent table are set if ($result['command'] !== 'new') { $table = $result['inlineTopMostParentTableName']; $uid = $result['inlineTopMostParentUid']; if (!empty($fullInlineState[$table][$uid])) { $inlineStateForTable = $fullInlineState[$table][$uid]; } } } else { // Default case for a single record if ($result['command'] !== 'new') { $table = $result['tableName']; $uid = $result['databaseRow']['uid'] ?? 0; if (!empty($fullInlineState[$table][$uid])) { $inlineStateForTable = $fullInlineState[$table][$uid]; } } } $result['inlineExpandCollapseStateArray'] = $inlineStateForTable; } if (!$result['isInlineChildExpanded']) { // If the record is an inline child that is not expanded, it is not necessary to calculate all fields $isExistingRecord = $result['command'] === 'edit'; $inlineConfig = $result['inlineParentConfig']; $collapseAll = isset($inlineConfig['appearance']['collapseAll']) && $inlineConfig['appearance']['collapseAll']; $expandAll = isset($inlineConfig['appearance']['collapseAll']) && !$inlineConfig['appearance']['collapseAll']; $expandCollapseStateArray = $result['inlineExpandCollapseStateArray']; $foreignTable = $result['inlineParentConfig']['foreign_table'] ?? null; $isExpandedByUcState = $foreignTable !== null && isset($expandCollapseStateArray[$foreignTable]) && is_array($expandCollapseStateArray[$foreignTable]) && in_array($result['databaseRow']['uid'], $expandCollapseStateArray[$foreignTable]) !== false; if (!$isExistingRecord || ($isExpandedByUcState && !$collapseAll) || $expandAll || $result['isInlineAjaxOpeningContext']) { $result['isInlineChildExpanded'] = true; } } return $result; } protected function getBackendUser(): BackendUserAuthentication { return $GLOBALS['BE_USER']; } }