Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v10 here: TYPO3 ELTS.
foreign_match_fields
foreign_match_fields
-
- Type
- array
- Path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']
- Scope
- Proc.
Array of field-value pairs to both insert and match against when writing/reading IRRE relations. Using the match fields, it is possible to re-use the same child table in more than one field of the parent table by using a match field with different values for each of the use cases.
Examples
Imagine you have a parent table called "company" and a child table called "persons". Now, if you want the company table to have two fields of type "inline", one called "employees" and one called "customers", both containing "persons". Then you could use a (hidden) field called "role" on the child (person) table to keep them apart. The match TCA configuration of the parent table would then look like this:
$GLOBALS['TCA']['ty_myext_company'] = [
'columns' => [
'employees' => [
'config' => [
'type' => 'inline',
'foreign_table' => 'ty_myext_person',
'foreign_field' => 'company',
'foreign_match_fields' => [
'role' => 'employee',
],
],
],
'customers' => [
'config' => [
'type' => 'inline',
'foreign_table' => 'ty_myext_person',
'foreign_field' => 'company',
'foreign_match_fields' => [
'role' => 'customer',
],
],
],
],
];
If the match field is made editable, for instance as a select drop-down of two values, the the relation would switch between the two parent fields after change an save. Imagine a user record having "open" and "closed" issues assigned, both pointing to the same table. The user then switches the status of an issue from "open" to "closed". On save, the issue would "move over" to the "closed" section in his view.