Project

General

Profile

Actions

Bug #72510

closed

Story #69617: FormEngine bugs

Markers (e.g. ###REC_FIELD_sys_language_uid###) not replaced in flexforms foreign_table_where tags

Added by Christian Brinkert almost 9 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Start date:
2016-01-03
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
7
PHP Version:
5.6
Tags:
Complexity:
Is Regression:
No
Sprint Focus:

Description

Problem description:
In previous TYPO3 Versions (4.5 and 6.2) Markers like "###REC_FIELD_*" will be replaced in flexform xml-files and "foreign_table_where" tags with the values of the current data row. In the current TYPO3 LTS 7.6.2 this will not be done if flexform fields are involved, only felxform values could be replaced. The language id could now not be used and no localization of entities from foreign tables are possible. I used this feature for localized select fields in the backend.

Problem research
As I found out the replacement will be done in

"TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvider" in method "processForeignTableClause" at line 973

$rowFieldValue = $result['databaseRow'][$whereClauseSubParts[0]];

But at this point the value of "$result['databaseRow']" contains only values of the flexform and not the whole database row. Just before the method "processForeignTableClause" would be called in class

"TYPO3\CMS\Backend\Form\FormDataProvider\TcaFlexProcess" at line 479

$flexSegmentResult = $formDataCompiler->compile($inputToFlexFormSegment);

the result array with potential replacement values will be recreated at line 444-454 in the same class.

$inputToFlexFormSegment = [
    // tablename of "parent" is given down for inline elements to resolve correctly
    'tableName' => $result['tableName'],
    'command' => '',
    'pageTsConfig' => $pageTsConfig,
    'databaseRow' => $tcaValueArray,
    'processedTca' => [
        'ctrl' => [],
        'columns' => [],
    ],
    'flexParentDatabaseRow' => $result['databaseRow'],
];

Problem cause
As you can see, the previous result values will be moved to the "flexParentDatabaseRow" key and only the fexform values will be set to the replacement relevant key "databaseRow", so "sys_language_uid" and other keys will now be ignored.

Problem solution
Don't know if the following suggestion is correct but an additional search in "flexParentDatabaseRow" array if no value could found in the "databaseRow" array would help ... at least for me. I've done the following code changes and attach this as a patch file - probably helps ...

"TYPO3\CMS\Backend\Form\FormDataProvider\AbstractItemProvide" line 973:

$rowFieldValue = $result['databaseRow'][$whereClauseSubParts[0]];

should be replaced with:

if (array_key_exists($whereClauseSubParts[0], $result['databaseRow'])){
    $rowFieldValue = $result['databaseRow'][$whereClauseSubParts[0]];
} else if (array_key_exists('flexParentDatabaseRow', $result)){
    $rowFieldValue = $result['flexParentDatabaseRow'][$whereClauseSubParts[0]];
} else {
    $rowFieldValue = null;
}

Hope this could be integrated, feedback welcom :-)


Files

20160103_foreignWhere.patch (1.54 KB) 20160103_foreignWhere.patch Christian Brinkert, 2016-01-03 12:13

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #76888: ###CURRENT_PID### in foreign_table_where of Flexforms always result in 0Closed2016-06-30

Actions
Actions

Also available in: Atom PDF