Bug #72510
closedStory #69617: FormEngine bugs
Markers (e.g. ###REC_FIELD_sys_language_uid###) not replaced in flexforms foreign_table_where tags
100%
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
Updated by Morton Jonuschat almost 9 years ago
- Category set to FormEngine aka TCEforms
- Target version changed from 7.6.3 to Candidate for patchlevel
Updated by Gerrit Code Review almost 9 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
Updated by Gerrit Code Review almost 9 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
Updated by Gerrit Code Review almost 9 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
Updated by Morton Jonuschat almost 9 years ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset b6483a83038f8a2928e8ac81e3ddc11360077902.