[BUGFIX] TCA: subtypes_addlist not processed 52/19652/3
authorErnesto Baschny <ernst@cron-it.de>
Sun, 11 Mar 2012 17:39:57 +0000 (18:39 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Tue, 20 Aug 2013 07:11:26 +0000 (09:11 +0200)
TCA: subtypes_addlist is not processed
if the subtype_value_field is in a palette

Change-Id: I6bcaaf36c330962c1d7d9fdd4a73ae502e9710dc
Fixes: #30636
Releases: 4.5, 4.7, 6.0, 6.1
Reviewed-on: https://review.typo3.org/19652
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
t3lib/class.t3lib_tceforms.php

index 86896a6..aab205d 100644 (file)
@@ -495,7 +495,7 @@ class t3lib_TCEforms {
 
                                                // Get excluded fields, added fiels and put it together:
                                        $excludeElements = $this->excludeElements = $this->getExcludeElements($table, $row, $typeNum);
-                                       $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum));
+                                       $fields = $this->mergeFieldsWithAddedFields($fields, $this->getFieldsToAdd($table, $row, $typeNum), $table);
 
                                                // If TCEforms will render a tab menu in the next step, push the name to the tab stack:
                                        $tabIdentString = '';
@@ -3279,15 +3279,36 @@ class t3lib_TCEforms {
         *
         * @param       array           A [types][showitem] list of fields, exploded by ","
         * @param       array           The output from getFieldsToAdd()
+        * @param       array           The table name, if we want to consider it's palettes when positioning the new elements
         * @return      array           Return the modified $fields array.
         * @see getMainFields(),getFieldsToAdd()
         */
-       function mergeFieldsWithAddedFields($fields, $fieldsToAdd) {
+       function mergeFieldsWithAddedFields($fields, $fieldsToAdd, $table = '') {
                if (count($fieldsToAdd[0])) {
                        $c = 0;
+                       $found = FALSE;
                        foreach ($fields as $fieldInfo) {
-                               $parts = explode(';', $fieldInfo);
-                               if (!strcmp(trim($parts[0]), $fieldsToAdd[1])) {
+                               list($fieldName, $label, $paletteName) = t3lib_div::trimExplode(';', $fieldInfo);
+                               if ($fieldName === $fieldsToAdd[1]) {
+                                       $found = TRUE;
+                               } elseif ($fieldName === '--palette--' && $paletteName && $table !== '') {
+                                       // Look inside the palette
+                                       if (is_array($GLOBALS['TCA'][$table]['palettes'][$paletteName])) {
+                                               $itemList = $GLOBALS['TCA'][$table]['palettes'][$paletteName]['showitem'];
+                                               if ($itemList) {
+                                                       $paletteFields = t3lib_div::trimExplode(',', $itemList, 1);
+                                                       foreach ($paletteFields as $info) {
+                                                               $fieldParts = t3lib_div::trimExplode(';', $info);
+                                                               $theField = $fieldParts[0];
+                                                               if ($theField === $fieldsToAdd[1]) {
+                                                                       $found = TRUE;
+                                                                       break 1;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+                               if ($found) {
                                        array_splice(
                                                $fields,
                                                $c + 1,