[BUGFIX] Set language uid for inline children by default 06/53206/6
authorSusanne Moog <s.moog@neusta.de>
Mon, 3 Jul 2017 06:02:23 +0000 (08:02 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Thu, 17 Aug 2017 21:33:45 +0000 (23:33 +0200)
On creating child records for an inline field, currently no language
is set and the children are stored with sys_language_uid 0. This patch
adds the proper configuration to ensure a default children language
according to its parent language.

Resolves: #48883
Resolves: #76048
Resolves: #73609
Releases: master, 7.6
Change-Id: Id9e449dbb06fed11670eedec45a92529fb4acb6f
Reviewed-on: https://review.typo3.org/53206
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Benni Mack <benni@typo3.org>
Reviewed-by: Susanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog <susanne.moog@typo3.org>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/backend/Classes/Controller/FormInlineAjaxController.php

index c846fd9..44dd8af 100644 (file)
@@ -21,6 +21,7 @@ use TYPO3\CMS\Backend\Form\FormDataGroup\InlineParentRecord;
 use TYPO3\CMS\Backend\Form\FormDataGroup\TcaDatabaseRecord;
 use TYPO3\CMS\Backend\Form\InlineStackProcessor;
 use TYPO3\CMS\Backend\Form\NodeFactory;
+use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
 use TYPO3\CMS\Core\DataHandling\DataHandler;
 use TYPO3\CMS\Core\Localization\LocalizationFactory;
@@ -131,20 +132,14 @@ class FormInlineAjaxController
         }
         $childData = $formDataCompiler->compile($formDataCompilerInput);
 
-        // Set language of new child record to the language of the parent record:
-        // @todo: To my understanding, the below case can't happen: With localizationMode select, lang overlays
-        // @todo: of children are only created with the "synchronize" button that will trigger a different ajax action.
-        // @todo: The edge case of new page overlay together with localized media field, this code won't kick in either.
-        /**
-        if ($parent['localizationMode'] === 'select' && MathUtility::canBeInterpretedAsInteger($parent['uid'])) {
-            $parentRecord = $inlineRelatedRecordResolver->getRecord($parent['table'], $parent['uid']);
+        // Set language of new child record to the language of the parent record
+        if ($parent['localizationMode'] !== 'keep' && MathUtility::canBeInterpretedAsInteger($parent['uid'])) {
+            $parentRecord = BackendUtility::getRecord($parent['table'], $parent['uid']);
             $parentLanguageField = $GLOBALS['TCA'][$parent['table']]['ctrl']['languageField'];
             $childLanguageField = $GLOBALS['TCA'][$child['table']]['ctrl']['languageField'];
-            if ($parentRecord[$parentLanguageField] > 0) {
-                $record[$childLanguageField] = $parentRecord[$parentLanguageField];
-            }
+            $childData['databaseRow'][$childLanguageField][0] = $parentRecord[$parentLanguageField];
         }
-         */
+
         if ($parentConfig['foreign_selector'] && $parentConfig['appearance']['useCombination']) {
             // We have a foreign_selector. So, we just created a new record on an intermediate table in $childData.
             // Now, if a valid id is given as second ajax parameter, the intermediate row should be connected to an