data['flexFormDataStructureArray']; $flexFormRowData = $this->data['flexFormRowData']; $flexFormFormPrefix = $this->data['flexFormFormPrefix']; $parameterArray = $this->data['parameterArray']; $languageService = $this->getLanguageService(); $resultArray = $this->initializeResultArray(); foreach ($flexFormDataStructureArray as $flexFormFieldName => $flexFormFieldArray) { if ( // No item array found at all !is_array($flexFormFieldArray) // Not a section or container and not a list of single items || (!isset($flexFormFieldArray['type']) && !is_array($flexFormFieldArray['config'])) ) { continue; } if (($flexFormFieldArray['type'] ?? null) === 'array') { // Section if (empty($flexFormFieldArray['section'])) { $resultArray['html'] = LF . 'Section expected at ' . $flexFormFieldName . ' but not found'; continue; } $options = $this->data; $options['flexFormDataStructureArray'] = $flexFormFieldArray; $options['flexFormRowData'] = $flexFormRowData[$flexFormFieldName]['el'] ?? []; $options['flexFormFieldName'] = $flexFormFieldName; $options['renderType'] = 'flexFormSectionContainer'; $sectionContainerResult = $this->nodeFactory->create($options)->render(); $resultArray = $this->mergeChildReturnIntoExistingResult($resultArray, $sectionContainerResult); } else { // Set up options for single element $fakeParameterArray = [ 'fieldConf' => [ 'label' => $languageService->sL(trim($flexFormFieldArray['label'] ?? '')), 'config' => $flexFormFieldArray['config'] ?? [], 'children' => $flexFormFieldArray['children'] ?? [], // https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Columns/Properties/OnChange.html 'onChange' => $flexFormFieldArray['onChange'] ?? '', ], 'fieldChangeFunc' => $parameterArray['fieldChangeFunc'], 'label' => $parameterArray['label'] ?? '', ]; if (isset($flexFormFieldArray['description']) && !empty($flexFormFieldArray['description'])) { $fakeParameterArray['fieldConf']['description'] = $flexFormFieldArray['description']; } if ($fakeParameterArray['fieldConf']['onChange'] === 'reload') { $confirmation = $this->getBackendUserAuthentication()->jsConfirmation(JsConfirmation::TYPE_CHANGE); $fakeParameterArray['fieldChangeFunc']['alert'] = new ReloadOnFieldChange($confirmation); } $originalFieldName = $parameterArray['itemFormElName']; $fakeParameterArray['itemFormElName'] = $parameterArray['itemFormElName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][vDEF]'; if ($fakeParameterArray['itemFormElName'] !== $originalFieldName) { // If calculated itemFormElName is different from originalFieldName // change the originalFieldName in TBE_EDITOR_fieldChanged. This is // especially relevant for wizards writing their content back to hidden fields $onFieldChange = $fakeParameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] ?? null; if ($onFieldChange instanceof UpdateValueOnFieldChange) { $fakeParameterArray['fieldChangeFunc']['TBE_EDITOR_fieldChanged'] = $onFieldChange->withElementName($fakeParameterArray['itemFormElName']); } } if (array_key_exists('vDEF', $flexFormRowData[$flexFormFieldName] ?? [])) { $fakeParameterArray['itemFormElValue'] = $flexFormRowData[$flexFormFieldName]['vDEF']; } else { $fakeParameterArray['itemFormElValue'] = $fakeParameterArray['fieldConf']['config']['default'] ?? ''; } $options = $this->data; // Set either flexFormFieldName or flexFormContainerFieldName, depending on if we are a "regular" field or a flex container section field if (empty($options['flexFormFieldName'])) { $options['flexFormFieldName'] = $flexFormFieldName; } else { $options['flexFormContainerFieldName'] = $flexFormFieldName; } $options['parameterArray'] = $fakeParameterArray; $options['elementBaseName'] = $this->data['elementBaseName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][vDEF]'; if (!empty($flexFormFieldArray['config']['renderType'])) { $options['renderType'] = $flexFormFieldArray['config']['renderType']; } else { // Fallback to type if no renderType is given $options['renderType'] = $flexFormFieldArray['config']['type']; } $childResult = $this->nodeFactory->create($options)->render(); if (!empty($childResult['html'])) { $html = []; $html[] = '