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 over 8 years ago. Updated over 5 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 #1

Updated by Morton Jonuschat over 8 years ago

  • Category set to FormEngine aka TCEforms
  • Target version changed from 7.6.3 to Candidate for patchlevel
Actions #2

Updated by Morton Jonuschat over 8 years ago

  • Parent task set to #69617
Actions #3

Updated by Gerrit Code Review over 8 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45597

Actions #4

Updated by Gerrit Code Review over 8 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45597

Actions #5

Updated by Gerrit Code Review over 8 years ago

Patch set 1 for branch TYPO3_7-6 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/45962

Actions #6

Updated by Morton Jonuschat over 8 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #7

Updated by Benni Mack over 5 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF