-) $pattern = '/^data-(.+?)-(.+)$/'; if (preg_match($pattern, $domObjectId, $match)) { $inlineFirstPid = $match[1]; $parts = explode('-', $match[2]); $partsCnt = count($parts); for ($i = 0; $i < $partsCnt; $i++) { if ($i > 0 && $i % 3 == 0) { // Store the TCA configuration of the table field in the stack $unstable['config'] = []; if ($schemaCollection->has($unstable['table'])) { $tableSchema = $schemaCollection->get($unstable['table']); if ($tableSchema->hasField($unstable['field'])) { $unstable['config'] = $tableSchema->getField($unstable['field'])->getConfiguration(); } } // Fetch TSconfig: $TSconfig = FormEngineUtility::getTSconfigForTableRow($unstable['table'], ['uid' => $unstable['uid'], 'pid' => $inlineFirstPid], $unstable['field']); // Override TCA field config by TSconfig: if (!isset($TSconfig['disabled']) || !$TSconfig['disabled']) { $unstable['config'] = FormEngineUtility::overrideFieldConf($unstable['config'], $TSconfig); } // Extract FlexForm from field part (if any) if (str_contains($unstable['field'], ':')) { $fieldParts = GeneralUtility::trimExplode(':', $unstable['field']); $unstable['field'] = array_shift($fieldParts); // FlexForm parts start with data: if (!empty($fieldParts) && $fieldParts[0] === 'data') { $unstable['flexform'] = $fieldParts; } } $structure['stable'][] = $unstable; $unstable = []; } $unstable[$vector[$i % 3]] = $parts[$i]; } $structure['unstable'] = $unstable; } return $structure; } /** * Injects configuration via AJAX calls. * This is used by inline ajax calls that transfer configuration options back to the stack for initialization. * * @param array $config Given config extracted from ajax call * @todo: Review this construct - Why can't the ajax call fetch these data on its own and transfers it to client instead? */ public function addAjaxConfigurationToStructure(array $structure, array $config): array { $lastStableStructureKey = count($structure['stable'] ?? []) - 1; if (empty($config) || $lastStableStructureKey < 0) { return $structure; } $structure['stable'][$lastStableStructureKey]['config'] = $config; return $structure; } /** * Prefix for inline form fields */ public function getFormPrefixFromStructure(array $structure): string { $current = $this->getStructureLevelFromStructure($structure, -1); if ($current) { return 'data' . $this->getStructureItemNameFromStructure($structure, $current, 'Disposal_AttributeName'); } return ''; } /** * DOM object-id for this inline level * * @param int|string $inlineFirstPid Pid of top level inline element storage or "NEW..." */ public function getDomObjectIdPrefixFromStructure(array $structure, int|string $inlineFirstPid): string { $current = $this->getStructureLevelFromStructure($structure, -1); // If there are still more inline levels available if ($current) { return 'data-' . $inlineFirstPid . '-' . $this->getStructurePathFromStructure($structure); } return ''; } /** * Get the identifiers of a given depth of level, from the top of the stack to the bottom. * An identifier looks like "--". * * @return string The path of identifiers */ private function getStructurePathFromStructure(array $structure): string { $structureLevels = []; $structureCount = count($structure['stable'] ?? []); for ($i = 1; $i <= $structureCount; $i++) { $currentStructure = $this->getStructureLevelFromStructure($structure, -$i) ?: []; $currentItem = $this->getStructureItemNameFromStructure($structure, $currentStructure, 'Disposal_AttributeId'); array_unshift($structureLevels, $currentItem); } return implode('-', $structureLevels); } /** * Create a name/id for usage in HTML output of a level of the structure stack to be used in form names. * * @param array $levelData Array of a level of the structure stack (containing the keys table, uid and field) * @param string $disposal How the structure name is used (e.g. as
or ) * @return string The name/id of that level, to be used for HTML output */ private function getStructureItemNameFromStructure(array $structure, array $levelData, string $disposal): string { $parts = [$levelData['table'], $levelData['uid']]; if (!empty($levelData['field'])) { $parts[] = $levelData['field']; } if ($disposal === 'Disposal_AttributeName') { // Use in name attributes $parent = $this->getStructureLevelFromStructure($structure, -1); if (!empty($levelData['field']) && !empty($levelData['flexform']) && $parent === $levelData) { $parts[] = implode('][', $levelData['flexform']); } $name = '[' . implode('][', $parts) . ']'; } else { // Use in object id attributes $name = implode('-', $parts); if (!empty($levelData['field']) && !empty($levelData['flexform'])) { array_unshift($levelData['flexform'], $name); $name = implode('---', $levelData['flexform']); } } return $name; } }