[TASK] FormEngine: Simplify element name resolving 62/39462/2
authorChristian Kuhn <lolli@schwarzbu.ch>
Mon, 11 May 2015 16:41:24 +0000 (18:41 +0200)
committerChristian Kuhn <lolli@schwarzbu.ch>
Mon, 11 May 2015 20:30:21 +0000 (22:30 +0200)
Data submitted by FormEngine to DataHandler is prefixed in four
different ways:
* data - Transferred data
* cmd - A dataHandler command to execute
* data_files - Contains uploaded files
* action[control] - Overwrite fields data for NULL handling

These four prefixes are given along from FormEngine to the
whole container and element structure and never change.

To simplify this stuff, the patch removes the prefixes and
hardcodes them, and introduces a new globalOptions
$elementBaseName that contains the stuff behind the prefixes.
Quite some methods can be simplified this way and become
more obvious. Usage of $elementBaseName will be extended
with the next patch.

Change-Id: I8103b1d2068382e0b01bbe5d9bd79aeba2d00b08
Resolves: #66894
Releases: master
Reviewed-on: http://review.typo3.org/39462
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl>
Tested-by: Wouter Wolters <typo3@wouterwolters.nl>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
15 files changed:
typo3/sysext/backend/Classes/Form/AbstractNode.php
typo3/sysext/backend/Classes/Form/Container/FlexFormElementContainer.php
typo3/sysext/backend/Classes/Form/Container/InlineControlContainer.php
typo3/sysext/backend/Classes/Form/Container/InlineRecordContainer.php
typo3/sysext/backend/Classes/Form/Container/SingleFieldContainer.php
typo3/sysext/backend/Classes/Form/Element/GroupElement.php
typo3/sysext/backend/Classes/Form/Element/SelectElement.php
typo3/sysext/backend/Classes/Form/FormDataTraverser.php
typo3/sysext/backend/Classes/Form/FormEngine.php
typo3/sysext/backend/Classes/Form/InlineRelatedRecordResolver.php
typo3/sysext/backend/Classes/Form/InlineStackProcessor.php
typo3/sysext/backend/Classes/Form/Utility/FormEngineUtility.php
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js
typo3/sysext/backend/Resources/Public/JavaScript/jsfunc.tbe_editor.js
typo3/sysext/backend/Tests/Unit/Form/InlineStackProcessorTest.php

index 975a698..ce376fc 100644 (file)
@@ -137,7 +137,7 @@ abstract class AbstractNode {
                        /** @var FormDataTraverser $traverser */
                        $traverseFields = GeneralUtility::trimExplode('|', substr($value, 6));
                        $traverser = GeneralUtility::makeInstance(FormDataTraverser::class);
-                       $value = $traverser->getTraversedFieldValue($traverseFields, $table, $row, $this->globalOptions['inlineFirstPid'], $this->globalOptions['prependFormFieldNames']);
+                       $value = $traverser->getTraversedFieldValue($traverseFields, $table, $row, $this->globalOptions['inlineFirstPid']);
                }
 
                return $value;
index e6b7316..c736dd2 100644 (file)
@@ -136,7 +136,6 @@ class FlexFormElementContainer extends AbstractContainer {
                                $fakeParameterArray['onFocus'] = $parameterArray['onFocus'];
                                $fakeParameterArray['label'] = $parameterArray['label'];
                                $fakeParameterArray['itemFormElName'] = $parameterArray['itemFormElName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']';
-                               $fakeParameterArray['itemFormElName_file'] = $parameterArray['itemFormElName_file'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']';
                                $fakeParameterArray['itemFormElID'] = $fakeParameterArray['itemFormElName'];
                                if (isset($flexFormRowData[$flexFormFieldName][$vDEFkey])) {
                                        $fakeParameterArray['itemFormElValue'] = $flexFormRowData[$flexFormFieldName][$vDEFkey];
@@ -146,6 +145,7 @@ class FlexFormElementContainer extends AbstractContainer {
 
                                $options = $this->globalOptions;
                                $options['parameterArray'] = $fakeParameterArray;
+                               $options['elementBaseName'] = $this->globalOptions['elementBaseName'] . $flexFormFormPrefix . '[' . $flexFormFieldName . '][' . $vDEFkey . ']';
                                /** @var NodeFactory $nodeFactory */
                                $nodeFactory = GeneralUtility::makeInstance(NodeFactory::class);
                                $child = $nodeFactory->create($flexFormFieldArray['TCEforms']['config']['type']);
index f5aa5e1..ca102e5 100644 (file)
@@ -111,7 +111,7 @@ class InlineControlContainer extends AbstractContainer {
                );
                // Extract FlexForm parts (if any) from element name, e.g. array('vDEF', 'lDEF', 'FlexField', 'vDEF')
                if (!empty($parameterArray['itemFormElName'])) {
-                       $flexFormParts = FormEngineUtility::extractFlexFormParts($parameterArray['itemFormElName'], $this->globalOptions['prependFormFieldNames']);
+                       $flexFormParts = FormEngineUtility::extractFlexFormParts($parameterArray['itemFormElName']);
                        if ($flexFormParts !== NULL) {
                                $newStructureItem['flexform'] = $flexFormParts;
                        }
@@ -119,13 +119,13 @@ class InlineControlContainer extends AbstractContainer {
                $inlineStackProcessor->pushStableStructureItem($newStructureItem);
 
                // e.g. data[<table>][<uid>][<field>]
-               $nameForm = $inlineStackProcessor->getCurrentStructureFormPrefix($this->globalOptions['prependFormFieldNames']);
+               $nameForm = $inlineStackProcessor->getCurrentStructureFormPrefix();
                // e.g. data-<pid>-<table1>-<uid1>-<field1>-<table2>-<uid2>-<field2>
                $nameObject = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
 
                // Get the records related to this inline record
                $inlineRelatedRecordResolver = GeneralUtility::makeInstance(InlineRelatedRecordResolver::class);
-               $relatedRecords = $inlineRelatedRecordResolver->getRelatedRecords($table, $field, $row, $parameterArray, $config, $this->globalOptions['inlineFirstPid'], $this->globalOptions['prependFormFieldNames']);
+               $relatedRecords = $inlineRelatedRecordResolver->getRelatedRecords($table, $field, $row, $parameterArray, $config, $this->globalOptions['inlineFirstPid']);
 
                // Set the first and last record to the config array
                $relatedRecordsUids = array_keys($relatedRecords['records']);
index 76d5900..fda4645 100644 (file)
@@ -89,7 +89,7 @@ class InlineRecordContainer extends AbstractContainer {
 
                // Send a mapping information to the browser via JSON:
                // e.g. data[<curTable>][<curId>][<curField>] => data-<pid>-<parentTable>-<parentId>-<parentField>-<curTable>-<curId>-<curField>
-               $formPrefix = $inlineStackProcessor->getCurrentStructureFormPrefix($this->globalOptions['prependFormFieldNames']);
+               $formPrefix = $inlineStackProcessor->getCurrentStructureFormPrefix();
                $domObjectId = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
                $this->inlineData['map'][$formPrefix] = $domObjectId;
 
@@ -151,18 +151,18 @@ class InlineRecordContainer extends AbstractContainer {
                                $top = $this->inlineStackProcessor->getStructureLevel(0);
                                $ucFieldName = 'uc[inlineView][' . $top['table'] . '][' . $top['uid'] . ']' . $appendFormFieldNames;
                                // Set additional fields for processing for saving
-                               $html .= '<input type="hidden" name="' . $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[pid]" value="' . $record['pid'] . '"/>';
+                               $html .= '<input type="hidden" name="data' . $appendFormFieldNames . '[pid]" value="' . $record['pid'] . '"/>';
                                $html .= '<input type="hidden" name="' . $ucFieldName . '" value="' . $isExpanded . '" />';
                        } else {
                                // Set additional field for processing for saving
-                               $html .= '<input type="hidden" name="' . $this->globalOptions['prependCmdFieldNames'] . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
+                               $html .= '<input type="hidden" name="cmd' . $appendFormFieldNames . '[delete]" value="1" disabled="disabled" />';
                                if (!$isExpanded
                                        && !empty($GLOBALS['TCA'][$foreign_table]['ctrl']['enablecolumns']['disabled'])
                                        && $ajaxLoad
                                ) {
                                        $checked = !empty($record['hidden']) ? ' checked="checked"' : '';
-                                       $html .= '<input type="checkbox" name="' . $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[hidden]_0" value="1"' . $checked . ' />';
-                                       $html .= '<input type="input" name="' . $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[hidden]" value="' . $record['hidden'] . '" />';
+                                       $html .= '<input type="checkbox" name="data' . $appendFormFieldNames . '[hidden]_0" value="1"' . $checked . ' />';
+                                       $html .= '<input type="input" name="data' . $appendFormFieldNames . '[hidden]" value="' . $record['hidden'] . '" />';
                                }
                        }
                        // If this record should be shown collapsed
@@ -264,12 +264,12 @@ class InlineRecordContainer extends AbstractContainer {
 
                        // If this is a new record, add a pid value to store this record and the pointer value for the intermediate table
                        if ($isNewRecord) {
-                               $comboFormFieldName = $this->globalOptions['prependFormFieldNames'] . '[' . $comboConfig['foreign_table'] . '][' . $comboRecord['uid'] . '][pid]';
+                               $comboFormFieldName = 'data[' . $comboConfig['foreign_table'] . '][' . $comboRecord['uid'] . '][pid]';
                                $resultArray['html'] .= '<input type="hidden" name="' . $comboFormFieldName . '" value="' . $comboRecord['pid'] . '" />';
                        }
                        // If the foreign_selector field is also responsible for uniqueness, tell the browser the uid of the "other" side of the relation
                        if ($isNewRecord || $config['foreign_unique'] === $foreign_selector) {
-                               $parentFormFieldName = $this->globalOptions['prependFormFieldNames'] . $appendFormFieldNames . '[' . $foreign_selector . ']';
+                               $parentFormFieldName = 'data' . $appendFormFieldNames . '[' . $foreign_selector . ']';
                                $resultArray['html'] .= '<input type="hidden" name="' . $parentFormFieldName . '" value="' . $comboRecord['uid'] . '" />';
                        }
                }
index 14e9bcf..a7ae43d 100644 (file)
@@ -89,10 +89,9 @@ class SingleFieldContainer extends AbstractContainer {
 
                // Override fieldConf by fieldTSconfig:
                $parameterArray['fieldConf']['config'] = FormEngineUtility::overrideFieldConf($parameterArray['fieldConf']['config'], $parameterArray['fieldTSConfig']);
-               $parameterArray['itemFormElName'] = $this->globalOptions['prependFormFieldNames'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
-               // Form field name, in case of file uploads
-               $parameterArray['itemFormElName_file'] = $this->globalOptions['prependFormFieldNames_file'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
-               $parameterArray['itemFormElID'] = $this->globalOptions['prependFormFieldNames'] . '_' . $table . '_' . $row['uid'] . '_' . $fieldName;
+               $parameterArray['itemFormElName'] = 'data[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
+               $parameterArray['itemFormElID'] = 'data_' . $table . '_' . $row['uid'] . '_' . $fieldName;
+               $newElementBaseName = $this->globalOptions['elementBaseName'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
 
                // The value to show in the form field.
                $parameterArray['itemFormElValue'] = $row[$fieldName];
@@ -160,6 +159,7 @@ class SingleFieldContainer extends AbstractContainer {
                        // Based on the type of the item, call a render function on a child element
                        $options = $this->globalOptions;
                        $options['parameterArray'] = $parameterArray;
+                       $options['elementBaseName'] = $newElementBaseName;
                        /** @var NodeFactory $childFactory */
                        $childFactory = GeneralUtility::makeInstance(NodeFactory::class);
                        $childElement = $childFactory->create($parameterArray['fieldConf']['config']['type']);
@@ -208,7 +208,7 @@ class SingleFieldContainer extends AbstractContainer {
                                        $checked = '';
                                }
 
-                               $formElementName = $this->globalOptions['prependFormFieldNames'] . '[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
+                               $formElementName = 'data[' . $table . '][' . $row['uid'] . '][' . $fieldName . ']';
                                $onChange = htmlspecialchars(
                                        'typo3form.fieldSetNull(' . GeneralUtility::quoteJSvalue($formElementName) . ', !this.checked)'
                                );
index 7fc1445..21a8e2d 100644 (file)
@@ -218,7 +218,7 @@ class GroupElement extends AbstractFormElement {
                                                $html .= '
                                                        <div id="' . $parameterArray['itemFormElID_file'] . '">
                                                                <input type="file"' . $multipleAttribute . '
-                                                                       name="' . $parameterArray['itemFormElName_file'] . $multipleFilenameSuffix . '"
+                                                                       name="data_files' . $this->globalOptions['elementBaseName'] . $multipleFilenameSuffix . '"
                                                                        size="35" onchange="' . implode('', $parameterArray['fieldChangeFunc']) . '"
                                                                />
                                                        </div>';
index a7668a7..2f35ee7 100644 (file)
@@ -424,7 +424,7 @@ class SelectElement extends AbstractFormElement {
                $uniqueIds = NULL;
                if (is_array($inlineParent) && $inlineParent['uid']) {
                        $inlineObjectName = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->globalOptions['inlineFirstPid']);
-                       $inlineFormName = $inlineStackProcessor->getCurrentStructureFormPrefix($this->globalOptions['prependFormFieldNames']);
+                       $inlineFormName = $inlineStackProcessor->getCurrentStructureFormPrefix();
                        if ($inlineParent['config']['foreign_table'] == $table && $inlineParent['config']['foreign_unique'] == $field) {
                                $uniqueIds = $this->globalOptions['inlineData']['unique'][$inlineObjectName . '-' . $table]['used'];
                                $PA['fieldChangeFunc']['inlineUnique'] = 'inline.updateUnique(this,\'' . $inlineObjectName
index e07a20e..a59a3c5 100644 (file)
@@ -71,27 +71,18 @@ class FormDataTraverser {
        protected $inlineFirstPid;
 
        /**
-        * General prefix of forms
-        *
-        * @var string
-        */
-       protected $prependFormFieldNames;
-
-       /**
         * Traverses the array of given field names by using the TCA.
         *
         * @param array $fieldNameArray The field names that should be traversed.
         * @param string $tableName The starting table name.
         * @param array $row The starting record row.
         * @param int $inlineFirstPid Inline first pid
-        * @param string $prependFormFieldNames General prefix of forms
         * @return mixed The value of the last field in the chain.
         */
-       public function getTraversedFieldValue(array $fieldNameArray, $tableName, array $row, $inlineFirstPid, $prependFormFieldNames) {
+       public function getTraversedFieldValue(array $fieldNameArray, $tableName, array $row, $inlineFirstPid) {
                $this->currentTable = $tableName;
                $this->currentRow = $row;
                $this->inlineFirstPid = $inlineFirstPid;
-               $this->prependFormFieldNames = $prependFormFieldNames;
                $fieldValue = '';
                if (count($fieldNameArray) > 0) {
                        $this->initializeOriginalLanguageUid();
@@ -244,7 +235,7 @@ class FormDataTraverser {
 
                $PA = array('itemFormElValue' => $value);
                $inlineRelatedRecordResolver = GeneralUtility::makeInstance(InlineRelatedRecordResolver::class);
-               $items = $inlineRelatedRecordResolver->getRelatedRecords($this->currentTable, $fieldName, $this->currentRow, $PA, $fieldConfig, $this->inlineFirstPid, $this->prependFormFieldNames);
+               $items = $inlineRelatedRecordResolver->getRelatedRecords($this->currentTable, $fieldName, $this->currentRow, $PA, $fieldConfig, $this->inlineFirstPid);
                if ($items['count'] > 0) {
                        $this->currentTable = $fieldConfig['foreign_table'];
                        foreach ($items['records'] as $inlineRecord) {
index 6f39419..7967553 100644 (file)
@@ -114,28 +114,6 @@ class FormEngine {
         */
        protected $renderReadonly = FALSE;
 
-       // INTERNAL, static
-       /**
-        * The string to prepend formfield names with.
-        *
-        * @var string
-        */
-       public $prependFormFieldNames = 'data';
-
-       /**
-        * The string to prepend commands for tcemain::process_cmdmap with
-        *
-        * @var string
-        */
-       public $prependCmdFieldNames = 'cmd';
-
-       /**
-        * The string to prepend FILE form field names with
-        *
-        * @var string
-        */
-       public $prependFormFieldNames_file = 'data_files';
-
        /**
         * @var InlineStackProcessor
         */
@@ -452,9 +430,7 @@ class FormEngine {
                        'databaseRow' => $this->databaseRow,
                        'additionalPreviewLanguages' => $this->additionalPreviewLanguages,
                        'localizationMode' => $this->localizationMode, // @todo: find out the details, Warning, this overlaps with inline behaviour localizationMode
-                       'prependFormFieldNames' => $this->prependFormFieldNames,
-                       'prependFormFieldNames_file' => $this->prependFormFieldNames_file,
-                       'prependCmdFieldNames' => $this->prependCmdFieldNames,
+                       'elementBaseName' => '',
                        'tabAndInlineStack' => array(),
                        'inlineFirstPid' => $this->getInlineFirstPid(),
                        'inlineExpandCollapseStateArray' => $this->getInlineExpandCollapseStateArrayForTableUid($this->table, $this->databaseRow['uid']),
@@ -1358,7 +1334,6 @@ class FormEngine {
                        // We want to load jQuery-ui inside our js. Enable this using requirejs.
                        $this->loadJavascriptLib('sysext/backend/Resources/Public/JavaScript/jsfunc.inline.js');
                        $out .= '
-                       inline.setPrependFormFieldNames("data");
                        inline.setNoTitleString("' . addslashes(BackendUtility::getNoRecordTitle(TRUE)) . '");
                        ';
 
@@ -1369,9 +1344,6 @@ class FormEngine {
                        TBE_EDITOR.formname = "' . $formname . '";
                        TBE_EDITOR.formnameUENC = "' . rawurlencode($formname) . '";
                        TBE_EDITOR.backPath = "";
-                       TBE_EDITOR.prependFormFieldNames = "' . $this->prependFormFieldNames . '";
-                       TBE_EDITOR.prependFormFieldNamesUENC = "' . rawurlencode($this->prependFormFieldNames) . '";
-                       TBE_EDITOR.prependFormFieldNamesCnt = ' . substr_count($this->prependFormFieldNames, '[') . ';
                        TBE_EDITOR.isPalettedoc = null;
                        TBE_EDITOR.doSaveFieldName = "' . ($this->doSaveFieldName ? addslashes($this->doSaveFieldName) : '') . '";
                        TBE_EDITOR.labels.fieldsChanged = ' . GeneralUtility::quoteJSvalue($languageService->sL('LLL:EXT:lang/locallang_core.xlf:labels.fieldsChanged')) . ';
index d1b191b..1a32434 100644 (file)
@@ -40,10 +40,9 @@ class InlineRelatedRecordResolver {
         * @param array $PA An array with additional configuration options.
         * @param array $config (Redundant) content of $PA['fieldConf']['config'] (for convenience)
         * @param integer $inlineFirstPid Inline first pid
-        * @param string $prependFormFieldNames General prefix of forms
         * @return array The records related to the parent item as associative array.
         */
-       public function getRelatedRecords($table, $field, $row, $PA, $config, $inlineFirstPid, $prependFormFieldNames) {
+       public function getRelatedRecords($table, $field, $row, $PA, $config, $inlineFirstPid) {
                $language = 0;
                $elements = $PA['itemFormElValue'];
                $foreignTable = $config['foreign_table'];
@@ -64,7 +63,7 @@ class InlineRelatedRecordResolver {
 
                                        // Checks if it is a flexform field
                                        if ($GLOBALS['TCA'][$table]['columns'][$field]['config']['type'] === 'flex') {
-                                               $flexFormParts = FormEngineUtility::extractFlexFormParts($PA['itemFormElName'], $prependFormFieldNames);
+                                               $flexFormParts = FormEngineUtility::extractFlexFormParts($PA['itemFormElName']);
                                                $flexData = GeneralUtility::xml2array($fieldValue);
                                                /** @var  $flexFormTools  FlexFormTools */
                                                $flexFormTools = GeneralUtility::makeInstance(FlexFormTools::class);
index 15b7f09..6f60625 100644 (file)
@@ -150,15 +150,14 @@ class InlineStackProcessor {
        /**
         * Prefix for inline form fields
         *
-        * @param string $prependFormFieldNames General prefix of forms
         * @return string
         */
-       public function getCurrentStructureFormPrefix($prependFormFieldNames) {
+       public function getCurrentStructureFormPrefix() {
                $current = $this->getStructureLevel(-1);
                $inlineFormName = '';
                // If there are still more inline levels available
                if ($current !== FALSE) {
-                       $inlineFormName = $prependFormFieldNames . $this->getStructureItemName($current, 'Disposal_AttributeName');
+                       $inlineFormName = 'data' . $this->getStructureItemName($current, 'Disposal_AttributeName');
                }
                return $inlineFormName;
        }
index dc7d1d5..9e1b956 100644 (file)
@@ -546,17 +546,15 @@ class FormEngineUtility {
         * Helper method used in inline
         *
         * @param string $formElementName The form element name
-        * @param string $prependFormFieldNames Prepended form field name
         * @return array|NULL
         * @internal
         */
-       static public function extractFlexFormParts($formElementName, $prependFormFieldNames) {
+       static public function extractFlexFormParts($formElementName) {
                $flexFormParts = NULL;
 
                $matches = array();
-               $prefix = preg_quote($prependFormFieldNames, '#');
 
-               if (preg_match('#^' . $prefix . '(?:\[[^]]+\]){3}(\[data\](?:\[[^]]+\]){4,})$#', $formElementName, $matches)) {
+               if (preg_match('#^data(?:\[[^]]+\]){3}(\[data\](?:\[[^]]+\]){4,})$#', $formElementName, $matches)) {
                        $flexFormParts = GeneralUtility::trimExplode(
                                '][',
                                trim($matches[1], '[]')
index 6c0374f..aa807e2 100644 (file)
@@ -23,7 +23,6 @@ var inline = {
        structureSeparator: '-',
        flexFormSeparator: '---',
        flexFormSubstitute: ':',
-       prependFormFieldNames: 'data',
        noTitleString: '[No title]',
        lockedAjaxMethod: {},
        sourcesLoaded: {},
@@ -38,9 +37,6 @@ var inline = {
                        TYPO3.jQuery.extend(inline.data[key], value);
                });
        },
-       setPrependFormFieldNames: function (value) {
-               this.prependFormFieldNames = value;
-       },
        setNoTitleString: function (value) {
                this.noTitleString = value;
        },
@@ -117,7 +113,7 @@ var inline = {
        },
        collapseAllRecords: function (objectId, objectPrefix, callingUid) {
                // get the form field, where all records are stored
-               var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 2, true);
+               var objectName = 'data' + this.parseObjectId('parts', objectId, 3, 2, true);
                var formObj = document.getElementsByName(objectName);
                var collapse = [];
 
@@ -431,9 +427,9 @@ var inline = {
                        return;
                }
 
-               var formName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 1, true);
+               var formName = 'data' + this.parseObjectId('parts', objectId, 3, 1, true);
                var formObj = document.getElementsByName(formName);
-               var recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
+               var recordObj = document.getElementsByName('data[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
                var values = this.getValuesFromHashMap(unique.used);
                if (recordObj.length) {
                        if (recordObj[0].hasOwnProperty('options')) {
@@ -458,9 +454,9 @@ var inline = {
                var unique = this.data.unique[objectId];
                if (unique.type == 'select') {
                        if (!(unique.selector && unique.max == -1)) {
-                               var formName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 1, true);
+                               var formName = 'data' + this.parseObjectId('parts', objectId, 3, 1, true);
                                var formObj = document.getElementsByName(formName);
-                               var recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
+                               var recordObj = document.getElementsByName('data[' + unique.table + '][' + recordUid + '][' + unique.field + ']');
                                var values = this.getValuesFromHashMap(unique.used);
                                if ($selector.length) {
                                        // remove all items from the new select-item which are already used in other children
@@ -489,7 +485,7 @@ var inline = {
                                if (formObj.length && selectedValue) {
                                        var records = formObj[0].value.split(',');
                                        for (var i = 0; i < records.length; i++) {
-                                               recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
+                                               recordObj = document.getElementsByName('data[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
                                                if (recordObj.length && records[i] != recordUid) {
                                                        var $recordObject = TYPO3.jQuery(recordObj[0]);
                                                        this.removeSelectOption($recordObject, selectedValue);
@@ -617,7 +613,7 @@ var inline = {
        },
 
        changeSorting: function (objectId, direction) {
-               var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 2, true);
+               var objectName = 'data' + this.parseObjectId('parts', objectId, 3, 2, true);
                var objectPrefix = this.parseObjectId('full', objectId, 0, 1);
                var formObj = document.getElementsByName(objectName);
 
@@ -659,7 +655,7 @@ var inline = {
 
        dragAndDropSorting: function (element) {
                var objectId = element.getAttribute('id').replace(/_records$/, '');
-               var objectName = inline.prependFormFieldNames + inline.parseObjectId('parts', objectId, 3, 0, true);
+               var objectName = 'data' + inline.parseObjectId('parts', objectId, 3, 0, true);
                var formObj = document.getElementsByName(objectName);
                var $element = TYPO3.jQuery(element);
 
@@ -730,7 +726,7 @@ var inline = {
                // if no records were passed, fetch them from form field
                if (typeof records == 'undefined') {
                        records = [];
-                       var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectPrefix, 3, 1, true);
+                       var objectName = 'data' + this.parseObjectId('parts', objectPrefix, 3, 1, true);
                        var formObj = document.getElementsByName(objectName);
                        if (formObj.length) {
                                records = formObj[0].value.split(',');
@@ -757,7 +753,7 @@ var inline = {
 
        memorizeAddRecord: function (objectPrefix, newUid, afterUid, selectedValue) {
                if (this.isBelowMax(objectPrefix)) {
-                       var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectPrefix, 3, 1, true);
+                       var objectName = 'data' + this.parseObjectId('parts', objectPrefix, 3, 1, true);
                        var formObj = document.getElementsByName(objectName);
 
                        if (formObj.length) {
@@ -849,7 +845,7 @@ var inline = {
                var records = formObj[0].value.split(',');
                var recordObj;
                for (var i = 0; i < records.length; i++) {
-                       recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
+                       recordObj = document.getElementsByName('data[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
                        if (recordObj.length && recordObj[0] != srcElement) {
                                var $recordObject = TYPO3.jQuery(recordObj[0]);
                                this.removeSelectOption($recordObject, srcElement.value);
@@ -887,7 +883,7 @@ var inline = {
                                return;
                        }
 
-                       var formName = this.prependFormFieldNames + this.parseObjectId('parts', objectPrefix, 3, 1, true);
+                       var formName = 'data' + this.parseObjectId('parts', objectPrefix, 3, 1, true);
                        var formObj = document.getElementsByName(formName);
                        if (!formObj.length) {
                                return;
@@ -897,7 +893,7 @@ var inline = {
                        var recordObj;
                        // walk through all inline records on that level and get the select field
                        for (var i = 0; i < records.length; i++) {
-                               recordObj = document.getElementsByName(this.prependFormFieldNames + '[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
+                               recordObj = document.getElementsByName('data[' + unique.table + '][' + records[i] + '][' + unique.field + ']');
                                if (recordObj.length) {
                                        var $recordObject = TYPO3.jQuery(recordObj[0]);
                                        this.readdSelectOption($recordObject, fieldObj[0].value, unique);
@@ -963,11 +959,11 @@ var inline = {
                                        childObjectId = this.data.map[inlineRecords.get(i).name];
                                        childTable = this.data.config[childObjectId].table;
                                        for (j = records.length - 1; j >= 0; j--) {
-                                               removeStack.push(this.prependFormFieldNames + '[' + childTable + '][' + records[j] + ']');
+                                               removeStack.push('data[' + childTable + '][' + records[j] + ']');
                                        }
                                }
                        }
-                       removeStack.push(this.prependFormFieldNames + shortName);
+                       removeStack.push('data' + shortName);
                        TBE_EDITOR.removeElementArray(removeStack);
                }
 
@@ -984,7 +980,7 @@ var inline = {
                }
 
                var recordCount = this.memorizeRemoveRecord(
-                       this.prependFormFieldNames + this.parseObjectId('parts', objectId, 3, 2, true),
+                       'data' + this.parseObjectId('parts', objectId, 3, 2, true),
                        recordUid
                );
 
@@ -1063,7 +1059,7 @@ var inline = {
                var elReturn;
 
                if (wrap == 'full') {
-                       elReturn = this.prependFormFieldNames + '[' + parts.join('][') + ']';
+                       elReturn = 'data[' + parts.join('][') + ']';
                        elReturn = elReturn.split(this.flexFormSubstitute).join('][');
                } else if (wrap == 'parts') {
                        elReturn = '[' + parts.join('][') + ']';
@@ -1079,7 +1075,7 @@ var inline = {
                var elReturn;
 
                if (wrap == 'full') {
-                       elReturn = this.prependFormFieldNames + this.structureSeparator + parts.join(this.structureSeparator);
+                       elReturn = 'data' + this.structureSeparator + parts.join(this.structureSeparator);
                        elReturn = elReturn.split(this.flexFormSubstitute).join(this.flexFormSeparator);
                } else if (wrap == 'parts') {
                        elReturn = this.structureSeparator + parts.join(this.structureSeparator);
@@ -1164,7 +1160,7 @@ var inline = {
 
        isBelowMax: function (objectPrefix) {
                var isBelowMax = true;
-               var objectName = this.prependFormFieldNames + this.parseObjectId('parts', objectPrefix, 3, 1, true);
+               var objectName = 'data' + this.parseObjectId('parts', objectPrefix, 3, 1, true);
                var formObj = document.getElementsByName(objectName);
 
                if (this.data.config && this.data.config[objectPrefix] && formObj.length) {
index d8a0a3d..2ed2a99 100644 (file)
@@ -44,9 +44,6 @@ var TBE_EDITOR = {
        isChanged: 0,
 
        backPath: '',
-       prependFormFieldNames: 'data',
-       prependFormFieldNamesUENC: 'data',
-       prependFormFieldNamesCnt: 0,
 
        isPalettedoc: null,
        doSaveFieldName: 0,
@@ -315,7 +312,7 @@ var TBE_EDITOR = {
        },
 
        fieldChanged_fName: function(fName,el) {
-               var idx=2+TBE_EDITOR.prependFormFieldNamesCnt;
+               var idx=2;
                var table = TBE_EDITOR.split(fName, "[", idx);
                var uid = TBE_EDITOR.split(fName, "[", idx+1);
                var field = TBE_EDITOR.split(fName, "[", idx+2);
@@ -326,8 +323,8 @@ var TBE_EDITOR = {
                TBE_EDITOR.fieldChanged(table,uid,field,el);
        },
        fieldChanged: function(table,uid,field,el) {
-               var theField = TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']['+field+']';
-               var theRecord = TBE_EDITOR.prependFormFieldNames+'['+table+']['+uid+']';
+               var theField = 'data['+table+']['+uid+']['+field+']';
+               var theRecord = 'data['+table+']['+uid+']';
                TBE_EDITOR.isChanged = 1;
 
                // modify the "field has changed" info by adding a class to the container element (based on palette or main field)
index 934200a..2a3eb5a 100644 (file)
@@ -72,7 +72,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -92,7 +92,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -113,7 +113,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -137,7 +137,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -162,7 +162,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -188,7 +188,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -216,7 +216,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                                        ),
                                ),
                                array(
-                                       'form' => 'pageId[parentTable][parentUid][parentField]',
+                                       'form' => 'data[parentTable][parentUid][parentField]',
                                        'object' => 'data-pageId-grandParentTable-grandParentUid-grandParentField---data---sDEF---lDEF---grandParentFlexForm---vDEF-parentTable-parentUid-parentField',
                                ),
                        ),
@@ -243,7 +243,7 @@ class InlineStackProcessorTest extends UnitTestCase {
                /** @var InlineStackProcessor|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface $subject */
                $subject = new InlineStackProcessor;
                $subject->initializeByParsingDomObjectIdString($string, FALSE);
-               $this->assertEquals($expectedFormName['form'], $subject->getCurrentStructureFormPrefix('pageId'));
+               $this->assertEquals($expectedFormName['form'], $subject->getCurrentStructureFormPrefix());
        }
 
        /**