TYPO3  7.6
FlexFormNoTabsContainer.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Backend\Form\Container;
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
27 {
33  public function render()
34  {
35  $table = $this->data['tableName'];
36  $row = $this->data['databaseRow'];
37  $fieldName = $this->data['fieldName']; // field name of the flex form field in DB
38  $parameterArray = $this->data['parameterArray'];
39  $flexFormDataStructureArray = $this->data['flexFormDataStructureArray'];
40  $flexFormRowData = $this->data['flexFormRowData'];
41  $resultArray = $this->initializeResultArray();
42 
43  // Flex ds was normalized in flex provider to always have a sheet.
44  // Determine this single sheet name, most often it ends up with sDEF, except if only one sheet was defined
45  $sheetName = array_pop(array_keys($flexFormDataStructureArray['sheets']));
46  $flexFormRowDataSubPart = $flexFormRowData['data'][$sheetName]['lDEF'] ?: [];
47 
48  // That was taken from GeneralUtility::resolveSheetDefInDS - no idea if it is important
49  unset($flexFormDataStructureArray['meta']);
50 
51  if (!is_array($flexFormDataStructureArray['sheets'][$sheetName]['ROOT']['el'])) {
52  $resultArray['html'] = 'Data Structure ERROR: No [\'ROOT\'][\'el\'] element found in flex form definition.';
53  return $resultArray;
54  }
55 
56  // Assemble key for loading the correct CSH file
57  // @todo: what is that good for? That is for the title of single elements ... see FlexFormElementContainer!
58  $dsPointerFields = GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['columns'][$fieldName]['config']['ds_pointerField'], true);
59  $parameterArray['_cshKey'] = $table . '.' . $fieldName;
60  foreach ($dsPointerFields as $key) {
61  if ((string)$row[$key] !== '') {
62  $parameterArray['_cshKey'] .= '.' . $row[$key];
63  }
64  }
65 
66  $options = $this->data;
67  $options['flexFormDataStructureArray'] = $flexFormDataStructureArray['sheets'][$sheetName]['ROOT']['el'];
68  $options['flexFormRowData'] = $flexFormRowDataSubPart;
69  $options['flexFormFormPrefix'] = '[data][' . $sheetName . '][lDEF]';
70  $options['parameterArray'] = $parameterArray;
71 
72  $options['renderType'] = 'flexFormElementContainer';
73  return $this->nodeFactory->create($options)->render();
74  }
75 }