[BUGFIX] null values and empty values must be ignored for label fields 14/55614/3
authorCybercraft <info@cybercraft.de>
Thu, 8 Feb 2018 19:02:54 +0000 (20:02 +0100)
committerJo Hasenau <info@cybercraft.de>
Thu, 8 Feb 2018 19:28:07 +0000 (20:28 +0100)
Otherwise empty elements without any value will not get translated

Change-Id: I5cc6e69af14077b573caf61b83b2575ad1faba28
Reviewed-on: https://review.typo3.org/55614
Reviewed-by: Jo Hasenau <info@cybercraft.de>
Tested-by: Jo Hasenau <info@cybercraft.de>
Classes/Model/L10nBaseService.php

index 35d3a97..6994b19 100644 (file)
@@ -319,6 +319,7 @@ class L10nBaseService
      */
     protected function _submitContentAsDefaultLanguageAndGetFlexFormDiff($accum, $inputArray)
     {
+        global $TCA;
         if (is_array($inputArray)) {
             // Initialize:
             /** @var FlexFormTools $flexToolObj */
@@ -340,11 +341,11 @@ class L10nBaseService
                         }
                         if (is_array($data['fields'])) {
                             foreach ($data['fields'] as $key => $tData) {
-                                if (is_array($tData) && isset($inputArray[$table][$elementUid][$key])) {
+                                if (is_array($tData) && array_key_exists($key, $inputArray[$table][$elementUid])) {
                                     list($Ttable, $TuidString, $Tfield, $Tpath) = explode(':', $key);
                                     list($Tuid, $Tlang, $TdefRecord) = explode('/', $TuidString);
-                                    if (!$this->createTranslationAlsoIfEmpty && $inputArray[$table][$elementUid][$key] == '' && $Tuid == 'NEW') {
-                                        //if data is empty do not save it
+                                    if (!$this->createTranslationAlsoIfEmpty && $inputArray[$table][$elementUid][$key] == '' && $Tuid == 'NEW' && $Tfield !== trim($TCA[$Ttable]['ctrl']['label'])) {
+                                        //if data is empty and the field is not the label field of that particular table, do not save it
                                         unset($inputArray[$table][$elementUid][$key]);
                                         continue;
                                     }