getLanguageService(); $flexFormDataStructureArray = $this->data['flexFormDataStructureArray']; $flexFormRowData = $this->data['flexFormRowData']; $flexFormFieldName = $this->data['flexFormFieldName']; $flexFormSheetName = $this->data['flexFormSheetName']; $userHasAccessToDefaultLanguage = $this->getBackendUserAuthentication()->checkLanguageAccess(0); $resultArray = $this->initializeResultArray(); // Render each existing container foreach ($flexFormDataStructureArray['children'] as $flexFormContainerIdentifier => $containerDataStructure) { $existingContainerData = $flexFormRowData[$flexFormContainerIdentifier]; $existingSectionContainerDataStructureType = key($existingContainerData); $existingContainerData = $existingContainerData[$existingSectionContainerDataStructureType]; $options = $this->data; $options['flexFormRowData'] = $existingContainerData['el']; $options['flexFormDataStructureArray'] = $containerDataStructure; $options['flexFormFormPrefix'] = $this->data['flexFormFormPrefix'] . '[' . $flexFormFieldName . '][el]'; $options['flexFormContainerName'] = $existingSectionContainerDataStructureType; $options['flexFormContainerIdentifier'] = $flexFormContainerIdentifier; $options['renderType'] = 'flexFormContainerContainer'; $flexFormContainerContainerResult = $this->nodeFactory->create($options)->render(); $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $flexFormContainerContainerResult); } $containerId = sprintf('flexform-section-container-%s-%s-%s-%s', $flexFormSheetName, $this->data['fieldName'], md5($flexFormFieldName), md5($this->data['elementBaseName'])); $sectionContainerId = sprintf('flexform-section-%s-%s-%s-%s', $flexFormSheetName, $this->data['fieldName'], md5($flexFormFieldName), md5($this->data['elementBaseName'])); $hashedSectionContainerId = 'section-' . md5($sectionContainerId); // "New container" handling: Creates buttons for each possible container with all relevant information for the ajax call. $containerTemplatesHtml = []; foreach ($flexFormDataStructureArray['el'] as $flexFormContainerName => $flexFormFieldDefinition) { $containerTitle = ''; if (!empty(trim($flexFormFieldDefinition['title']))) { $containerTitle = $languageService->sL(trim($flexFormFieldDefinition['title'])); } $containerTemplateHtml = []; $containerTemplateHtml[] = 'data['vanillaUid'] . '"'; // no int cast for databaseRow uid, this can be "NEW1234..." $containerTemplateHtml[] = 'data-databaserowuid="' . htmlspecialchars($this->data['databaseRow']['uid']) . '"'; $containerTemplateHtml[] = 'data-command="' . htmlspecialchars($this->data['command']) . '"'; $containerTemplateHtml[] = 'data-tablename="' . htmlspecialchars($this->data['tableName']) . '"'; $containerTemplateHtml[] = 'data-fieldname="' . htmlspecialchars($this->data['fieldName']) . '"'; $containerTemplateHtml[] = 'data-recordtypevalue="' . $this->data['recordTypeValue'] . '"'; $containerTemplateHtml[] = 'data-flexformsheetname="' . htmlspecialchars($flexFormSheetName) . '"'; $containerTemplateHtml[] = 'data-flexformfieldname="' . htmlspecialchars($flexFormFieldName) . '"'; $containerTemplateHtml[] = 'data-flexformcontainername="' . htmlspecialchars($flexFormContainerName) . '"'; $containerTemplateHtml[] = 'data-target="#' . htmlspecialchars($hashedSectionContainerId) . '"'; $containerTemplateHtml[] = '>'; $containerTemplateHtml[] = $this->iconFactory->getIcon('actions-document-new', IconSize::SMALL)->render(); $containerTemplateHtml[] = htmlspecialchars(GeneralUtility::fixed_lgd_cs($containerTitle, 30)); $containerTemplateHtml[] = ''; $containerTemplatesHtml[] = implode(LF, $containerTemplateHtml); } // Create new elements links $createElementsHtml = []; if ($userHasAccessToDefaultLanguage) { $createElementsHtml[] = '