Project

General

Profile

Actions

Bug #101962

open

New records created on a field of type INLINE have the wrong sys_language_uid value

Added by Philipp Wrann about 1 year ago. Updated 8 months ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Start date:
2024-03-14
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When adding a field of type "inline" to a pi_flexform structure, a new created inline relation record does not have the language value of the parent record. When using the same config on a regular TCA field the new record will have the correct sys_language_uid (synced with the parent).

This is a variation (only names and labels changed) of the flexform:

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
    <meta>
        <langDisable>1</langDisable>
    </meta>
    <sheets>
        <sDEF>
            <ROOT>
                <TCEforms>
                    <sheetTitle>Settings</sheetTitle>
                </TCEforms>
                <type>array</type>
                <el>
                    <records>
                        <TCEforms>
                            <label>Records</label>
                            <config>
                                <type>inline</type>
                                <foreign_table>tx_some_record</foreign_table>
                                <foreign_field>parent_uid</foreign_field>
                                <foreign_table_field>parent_table</foreign_table_field>
                                <foreign_match_fields>
                                    <role>some_role</role>
                                </foreign_match_fields>
                                <foreign_sortby>sorting</foreign_sortby>
                                <maxitems>3</maxitems>
                                <appearance>
                                    <collapseAll>0</collapseAll>
                                    <newRecordLinkTitle>Add new record</newRecordLinkTitle>
                                    <useSortable>1</useSortable>
                                </appearance>
                                <behaviour>
                                    <enableCascadingDelete>1</enableCascadingDelete>
                                </behaviour>
                                <overrideChildTca>
                                    <columns>
                                        <some_field>
                                            <config>
                                                <default>1</default>
                                            </config>
                                        </some_field>
                                    </columns>
                                </overrideChildTca>
                            </config>
                        </TCEforms>
                    </records>
                </el>
            </ROOT>
        </sDEF>
    </sheets>
</T3DataStructure>

This is the relevant part of the TCA for tx_some_record

<?php
return [
    'ctrl' => [
        'label' => 'text',
        'title' => 'Some record',
        'type' => 'type',
        'typeicon_classes' => [
            'default' => 'tx-some-record',
        ],
        'rootLevel' => 0,
        'hideTable' => true,
        'delete' => 'deleted',
        'enablecolumns' => [
            'disabled' => 'hidden',
        ],
        'sortby' => 'sorting',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'cruser_id' => 'cruser_id',
        'transOrigPointerField' => 'l18n_parent',
        'transOrigDiffSourceField' => 'l18n_diffsource',
        'languageField' => 'sys_language_uid',
        'translationSource' => 'l10n_source',
    ],
    'interface' => [
        'maxDBListItems' => 30,
        'maxSingleDBListItems' => 50,
    ],
    'columns' => [
        'sys_language_uid' => [
            'exclude' => true,
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language',
            'config' => [
                'type' => 'language',
            ],
        ],
        'l18n_parent' => [
            'displayCond' => 'FIELD:sys_language_uid:>:0',
            'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'items' => [
                    [
                        '',
                        0
                    ]
                ],
                'foreign_table' => 'tx_some_record',
                'foreign_table_where' => 'AND tx_some_record.pid=###CURRENT_PID### AND tx_some_record.sys_language_uid IN (-1,0)',
                'default' => 0
            ],
        ],
        'l10n_source' => [
            'config' => [
                'type' => 'passthrough'
            ],
        ],
        'l18n_diffsource' => [
            'config' => [
                'type' => 'passthrough',
                'default' => ''
            ],
        ],
        'type' => [
            'config' => [
                'type' => 'user',
                'renderType' => 'hidden',
                'default' => '0',
            ],
        ],
        // other fields
    ],
    'types' => [
        // ...
    ],
    'palettes' => [
        // ...
    ],
];


Files

TcaFlexProcess.php (39.7 KB) TcaFlexProcess.php Kai Strecker, 2024-03-08 09:13
DataHandler.php (486 KB) DataHandler.php Kai Strecker, 2024-03-08 09:13

Related issues 3 (2 open1 closed)

Related to TYPO3 Core - Bug #76048: IRRE: Child records - New record doesn't get language of parent (non localized records but using new button)ClosedJo Hasenau2016-05-04

Actions
Related to TYPO3 Core - Story #101560: FlexForm related translation issuesNew2023-08-03

Actions
Related to TYPO3 Core - Bug #103393: New IRRE (inline) records created within FlexForm have the wrong sys_language_uid valueUnder Review2024-03-14

Actions
Actions #1

Updated by Georg Ringer about 1 year ago

to ease a possible bugfix, can you please share your flexforms, thanks

Actions #2

Updated by Philipp Wrann about 1 year ago

  • Description updated (diff)

Yes, sorry. Updated the description with relevant information.

Updated by Kai Strecker 9 months ago

Hi,

I encountered the same bug and two more and made some changes in our local TYPO3 source code to hotfix it.

There are actually three situations, where there is a bug with flexform, field type "inline" and translations:
  1. Create a record with sys_language_uid != 0 (page translation is in free mode) and in it create a record in a flexform field with type "inline" (bug reported by Philipp Wrann).
  2. Create a record with sys_language_uid = 0 and in it create a record in a flexform field with type "inline". Then translate the parent record. Bug: the inline record in the translated parent record has sys_language_uid = 0 instead of the same language as its parent record.
  3. Delete the translated parent record. Bug: the inline record of the translated parent record is not deleted.

Cause of bug 1

When editing the parent record, in the JavaScript variable TYPO3.settings.FormEngineInline.config['data-228-tt_content-43104-pi_flexform---data---sDEF---lDEF---images---vDEF-sys_file_reference'].context.config (the index "data-228-tt_content-...-sys_file_reference" being an example value) is a JSON string, which is missing inline.parentSysLanguageUid = SYS_LANGUAGE_UID_OF_PARENT_RECORD. This has to be fixed in typo3/sysext/backend/Classes/Form/FormDataProvider/TcaFlexProcess.php (see attached patched file).

Cause of bug 2

The translation is done by typo3/sysext/core/Classes/DataHandling/DataHandler.php::localize, which calls DataHandler::copyRecord, which calls DataHandler::copyRecord_procBasedOnFieldType for every field. The function call chain continues for flexform fields with DataHandler::checkValue_flex_procInData and DataHandler::checkValue_flex_procInData_travDS. Then the passed callback function DataHandler::copyRecord_flexFormCallBack is called for every field in the flexform. Here, DataHandler::copyRecord_procBasedOnFieldType is called for every field in the flexform. The problem here is, that the target language is hard-coded to 0. This should instead be the language of the translated parent record.

Cause of bug 3

When deleting a record (DataHandler::deleteAction), after a few function calls (similar to the functions calls in "Cause of bug 2"), the function DataHandler::deleteRecord_procBasedOnFieldType is being called for every field of the record, that is to be deleted. But this function completely ignores flexform fields. I did a very incomplete hotfix, which only works for tt_content records with CType "gridelements_pi1", that have sys_file_reference inline records. A proper fix should probably use DataHandler::checkValue_flex_procInData to traverse all fields in the flexform.

I have attached patched versions of both files. My patches are surrounded by "@WD_PATCH start" and "@WD_PATCH end". I am not sure, if my patches are done in the most correct/nicest way. So, they definitely have to be reviewed, but should at least provide a proof-of-concept fix.

I hope this information helps fixing the bugs :)

Actions #4

Updated by Daniel Siepmann 8 months ago

  • Is duplicate of Bug #76048: IRRE: Child records - New record doesn't get language of parent (non localized records but using new button) added
Actions #5

Updated by Daniel Siepmann 8 months ago

  • Is duplicate of deleted (Bug #76048: IRRE: Child records - New record doesn't get language of parent (non localized records but using new button))
Actions #6

Updated by Daniel Siepmann 8 months ago

  • Related to Bug #76048: IRRE: Child records - New record doesn't get language of parent (non localized records but using new button) added
Actions #7

Updated by Daniel Siepmann 8 months ago

  • Related to Story #101560: FlexForm related translation issues added
Actions #8

Updated by Daniel Siepmann 8 months ago ยท Edited

I've splitted Cause 1 into separate issue #103393 in order to tackle that one with a dedicated patch.

Actions #9

Updated by Daniel Siepmann 8 months ago

  • Subtask #103393 added
Actions #10

Updated by Daniel Siepmann 8 months ago

  • Subtask deleted (#103393)
Actions #11

Updated by Daniel Siepmann 8 months ago

  • Related to Bug #103393: New IRRE (inline) records created within FlexForm have the wrong sys_language_uid value added
Actions

Also available in: Atom PDF