IRRE / inline
New in version 13.0
TYPO3 generates the correct database fields
for the inline type. Developers do not need to define this field in an extension
ext_tables.sql file.
Inline Relational Record Editing (IRRE) is a convenient way of editing parent-child relations in the backend. New child records can be created directly in the backend view (by AJAX call, so that the backend view is not reloaded).
The database field is generated automatically.
Note
Inline fields should not be used to handle files. Use TCA column type file.
The 'inline' TCA type is a powerful element that handles links between records.
It can handle 1:,
nested 1: and m: relations and the
different views and localizations. When used with
'ctrl' and 'types' properties, many different backend views are possible.
The inline type is mainly used to handle 1: relations (1 to many),
where one parent record has many children and each child has only one
parent. A child record cannot be moved between parents.
However, the inline type can also be used for m: relations (many to many).
An m: relation is where a child has many parents. The relation is set up
using an intermediate table.
The intermediate table contains the parent and child relation fields as well as any extra fields
providing additional information about the relation. One example of this is
"FAL" / resource handling in the Core. A parent record
(in table "tt_content") is linked to
a media resource in "sys_file" via the intermediate table "sys_file_reference".
The sys_file child record has itself table "sys_file_metadata"
as a child record holding meta information about the file (for example, a
description). This information can be overwritten for a file resource used by
"tt_content" by adding a new description in "sys_file_reference". TCA properties
such as "placeholders" can be used to set this up.
Hint
The inline type does not have field,
field or field properties like other types
because it is a container rather than an element. You can
still add fieldInformation or fieldWizard, but they must be configured
in the ctrl. See
example.
Table of contents:
Properties of the TCA column type inline
| Name | Type | Scope |
|---|---|---|
| array | Display | |
| boolean | Display | |
| boolean | Display | |
| boolean | Display | |
| boolean | ||
| plain text label or label reference | ||
| plain text label or label reference | ||
| string | ||
| boolean | ||
| boolean | ||
| boolean | ||
| boolean | ||
| boolean | ||
| boolean | ||
| array | ||
| boolean | ||
| boolean | ||
| integer | Display | |
| boolean | Proc. | |
| boolean | Proc. | |
| boolean | Proc. | |
| array | Display | |
| array | Display / Proc. | |
| string | Display | |
| string | Display / Proc. | |
| string | Display / Proc. | |
| array | Proc. | |
| string | Display / Proc. | |
| string | Display / Proc. | |
| string (table name) | Display / Proc. | |
| string | Display / Proc. | |
| string | Display / Proc. | |
| integer > 0 | Display / Proc. | |
| integer > 0 | Display | |
| string (table name) | Proc. | |
| string (field name) | Proc. | |
| array | Display | |
| string | Proc. | |
| integer | Display | |
| string | Display / Proc. | |
| string | Display / Proc. | |
| string | Display / Proc. |
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']
- Scope
- Display
Has information about the appearance of child records, namely:
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['collapseAll']
- Scope
- Display
Show all child records collapsed (if false, all are expanded)
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['expandSingle']
- Scope
- Display
Show only one child record expanded at a time. If a collapsed record is clicked, the currently open record collapses and the clicked on one expands.
-
- Type
- boolean
- Default
- True
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['showNewRecordLink']
- Scope
- Display
Disables the New record link in TCA
inlineelements without simultaneously disabling the + button in the header of each inline record (using['appearance']).['enabled Controls'] ['new']
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['newRecordLinkAddTitle']
Adds the title of the foreign_table to the "New record" link.
- false
- "Create new"
- true
- "Create new <title of foreign_table>", e.g. "Create new address"
-
- Type
- plain text label or label reference
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['newRecordLinkTitle']
Overrides the title of the "New record" link with a localized string. This will work only if
newis not set to true.Record Link Add Title Example:
'newRecordLinkTitle' => 'LLL:my_extension.db:my_new_record_label',Copied!
-
- Type
- plain text label or label reference
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['createNewRelationLinkTitle']
Overrides the link text and title of the "Create new relation" button with a localised string. Only useful if the element browser is enabled. This is usually used together with FAL relations to change it to "Add file" or similar.
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['levelLinksPosition']
- Values
- 'top' (default), 'bottom', 'both'.
Defines where to show the "New record" link in relation to the child records. Value 'none' is no longer supported, use
show,All Localization Link showandSynchronization Link showwith valueNew Record Link falseinstead.
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['useCombination']
This is only useful on bidirectional relations using an intermediate table with attributes. In a "combination" it is possible to edit the attributes AND the related child record itself. If using a foreign_selector, the foreign_unique property must be set to the same field as the foreign_selector.
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['suppressCombinationWarning']
Suppresses the warning flash message that will be displayed when using useCombination. You can also override the message with your own message using the example below.
EXT:my_extension/Configuration/TCA/Overrides/126-tx_myextension_conference-registrations.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [ 'registrations' => [ 'label' => 'my_extension.db:conference.registrations', 'config' => [ 'type' => 'inline', 'foreign_table' => 'tx_myextension_registration', 'foreign_field' => 'conference', 'foreign_selector' => 'attendee', 'foreign_unique' => 'attendee', 'foreign_match_fields' => [ 'status' => 'confirmed', ], 'appearance' => [ 'useCombination' => true, 'overwriteCombinationWarningMessage' => 'my_extension.db:conference.registrations.combinationWarning', ], 'overrideChildTca' => [ 'columns' => [ 'attendee' => [ 'config' => [ // The frontend users are stored in the same folder as the conferences 'elementBrowserEntryPoints' => [ 'fe_users' => '###CURRENT_PID###', ], ], ], ], ], ], ], ]); ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_conference', '--div--;my_extension.db:tab.registrations, registrations', '', 'before:--div--;my_extension.db:tab.details', );
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['useSortable']
Activate drag & drop sorting.
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['showPossibleLocalizationRecords']
Show unlocalized records which are in the original language but not yet localized.
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['showAllLocalizationLink']
Defines whether to show the "localize all records" link to fetch untranslated records from the original language.
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['showSynchronizationLink']
Defines whether to show a "synchronize" link to update to a 1:1 translation with the original language.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['enabledControls']
Associative array with keys 'info', 'new', 'dragdrop', 'sort', 'hide', 'delete', 'localize'. If a value is set to a boolean (true or false), the respective control is shown/hidden in the record header.
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['showPossibleRecordsSelector']
Can be used to hide the foreign record selector from the interface, even if you have a foreign_selector configured. This can be used to keep the technical functionality of the foreign_selector but is useful if you want to replace it with your own implementation using a custom control, see customControls.
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['appearance']['elementBrowserEnabled']
Hides or displays the element browser button in inline records
-
- Type
- integer
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['autoSizeMax']
- Scope
- Display
The maximum size (height) of the select field.
The size of the select field will be automatically adjusted based on the number of selected items. The select field will never be smaller than the specified size and never larger than the value of
auto.Size Max Note
Only has an effect if maxitems is greater than 1.
-
-
- Type
- boolean
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['behaviour']['allowLanguageSynchronization']
- Scope
- Proc.
Allows an editor to select in a localized record whether the value is copied over from default or source language record, or if the field has an own value in the localization. If set to true and if the table supports localization and if a localized record is edited, this setting enables FieldWizard LocalizationStateSelector: Two or three radio buttons shown below the field input. The state of this is stored in a json encoded array in the database table called
l10n_. It tells the DataHandler which fields of the localization records should be kept in sync if the underlying default or source record changes.state EXT:my_extension/Configuration/TCA/Overrides/159-tx_myextension_conference-content_elements.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [ 'content_elements' => [ 'label' => 'my_extension.db:conference.content_elements', 'config' => [ 'type' => 'inline', 'foreign_table' => 'tt_content', 'foreign_field' => 'tx_myextension_conference', 'behaviour' => [ 'allowLanguageSynchronization' => true, ], 'overrideChildTca' => [ 'columns' => [ 'CType' => [ 'config' => [ 'default' => 'text', ], ], ], 'types' => [ 'text' => [ 'showitem' => 'CType, header, bodytext', ], ], ], ], ], ]); ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_conference', 'content_elements', '', 'before:--div--;core.form.tabs:categories', );
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['behaviour']['disableMovingChildrenWithParent']
- Scope
- Proc.
Default false. Disables that child records get moved along with their parent records. Usually if in a parent-child relation a parent record is moved to a different page (eg. via cut+paste from clipboard), the children are relocated along with the parent. This flag disables the child move.
This property can be especially useful if all child records should be gathered in one storage folder and their parents are spread out at different places in the page tree. In combination with the Tsconfig setting
TCAdefaults.<table>.children can be forced to be created in this folder and stay there.pid = <page id>
-
- Type
- boolean
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['behaviour']['enableCascadingDelete']
- Scope
- Proc.
Default true. Usually in inline relations, if a parent is deleted, all children are deleted along with the parent. This flag can be used to disable that cascading delete. Example usage: A frontend user (parent) has assigned invoices (children). If a frontend user is deleted, it could be useful to keep the invoices.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['customControls']
- Scope
- Display
Numerical array containing definitions of custom header controls for IRRE fields. This makes it possible to create special controls by calling user-defined functions (userFuncs). Each item in the array item must be an array itself, with at least on key "userFunc" pointing to the user function to call.
The userFunc string is defined as usual in TYPO3 as ['class']->['method'], e.g.:
MyClass::class . '->myUserFuncMethod'Copied!For more details, see the implementation in
TYPO3\\and search for "customControls".CMS\\ Backend\\ Form\\ Container\\ Inline Control Container
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['filter']
- Scope
- Display / Proc.
Possibility to define user functions to filter out child items.
This is useful in special scenarios when used in conjunction with a foreign_selector where only certain foreign records are allowed to be related to.
For further documentation on this feature, see the "filter" documentation under TYPE: "group".
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_default_sortby']
- Scope
- Display
If a field name for foreign_sortby is defined, then this is ignored. Otherwise, this is used as the "ORDER BY" statement to sort the records in the table when listed.
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_field']
- Scope
- Display / Proc.
The
foreign_is the field of the child record pointing to the parent record. This defines where to store the uid of the parent record.field
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_label']
- Scope
- Display / Proc.
Insert the fieldname of the inline element, that you want to have as the title of the inline element. E.g. 'header'. If set, it overrides the label set in
$GLOBALSfor the inline-view.['TCA'] [<foreign_ table>] ['ctrl'] ['label']
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_match_fields']
- 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.
A conference has two fields of type "inline", registrations and
waiting_. Both contain registrations. The field status of the
registration, which the form does not show, keeps them apart:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'registrations' => [
'label' => 'my_extension.db:conference.registrations',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_myextension_registration',
'foreign_field' => 'conference',
'foreign_selector' => 'attendee',
'foreign_unique' => 'attendee',
'foreign_match_fields' => [
'status' => 'confirmed',
],
'appearance' => [
'useCombination' => true,
'overwriteCombinationWarningMessage' => 'my_extension.db:conference.registrations.combinationWarning',
],
'overrideChildTca' => [
'columns' => [
'attendee' => [
'config' => [
// The frontend users are stored in the same folder as the conferences
'elementBrowserEntryPoints' => [
'fe_users' => '###CURRENT_PID###',
],
],
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'--div--;my_extension.db:tab.registrations, registrations',
'',
'before:--div--;my_extension.db:tab.details',
);
The waiting list of a conference
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'waiting_list' => [
'label' => 'my_extension.db:conference.waiting_list',
'config' => [
'type' => 'inline',
// The same table as the registrations, kept apart by the status
'foreign_table' => 'tx_myextension_registration',
'foreign_field' => 'conference',
'foreign_selector' => 'attendee',
'foreign_unique' => 'attendee',
'foreign_match_fields' => [
'status' => 'waiting',
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'waiting_list',
'',
'after:registrations',
);
If the match field is made editable, for instance as a select drop-down of two values, the relation would switch between the two parent fields after change and save. If an editor changed the status of a registration from "waiting" to "confirmed", the registration would move from the waiting list to the registrations on save.
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_selector']
- Scope
- Display / Proc.
A selector is used to show all possible child records that could be used to create a relation with the parent record. It will be rendered as a multi-select-box. On clicking on an item inside the selector a new relation is created. The
foreign_points to a field of the foreign_table that is responsible for providing a selector-box – this field on theselector foreign_usually is of type select and also has atable foreign_defined.table In most cases you must assign the field
uid_to thelocal foreign_. This field name is used as a convention for the child record of the intermediate table. The automatic generation of MM tables also uses this field name. It depends whetherselector uid_of the MM table points to the opposite table (of the perspective of your inline field). In case of the opposite direction the field namelocal uid_is usually used.foreign Using a group field as foreign selectorThe field referenced by
foreign_can also be of type group. The child records are then selected from the table defined in its allowed option. Only one table is supported here: ifselector allowedlists several tables, only the first one is used.A conference lists its registrations. Each registration refers to a frontend user, and the intermediate table stores the ticket of this user. The group field
attendeeof the intermediate table is the selector: an editor picks a frontend user, and a new registration is created for it:
The registrations of a conference
EXT:my_extension/Configuration/TCA/Overrides/126-tx_myextension_conference-registrations.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [ 'registrations' => [ 'label' => 'my_extension.db:conference.registrations', 'config' => [ 'type' => 'inline', 'foreign_table' => 'tx_myextension_registration', 'foreign_field' => 'conference', 'foreign_selector' => 'attendee', 'foreign_unique' => 'attendee', 'foreign_match_fields' => [ 'status' => 'confirmed', ], 'appearance' => [ 'useCombination' => true, 'overwriteCombinationWarningMessage' => 'my_extension.db:conference.registrations.combinationWarning', ], 'overrideChildTca' => [ 'columns' => [ 'attendee' => [ 'config' => [ // The frontend users are stored in the same folder as the conferences 'elementBrowserEntryPoints' => [ 'fe_users' => '###CURRENT_PID###', ], ], ], ], ], ], ], ]); ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_conference', '--div--;my_extension.db:tab.registrations, registrations', '', 'before:--div--;my_extension.db:tab.details', );EXT:my_extension/Configuration/TCA/tx_myextension_registration.php<?php return [ 'ctrl' => [ 'title' => 'my_extension.db:registration', 'label' => 'attendee', 'label_alt' => 'ticket', 'label_alt_force' => true, 'hideTable' => true, 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'delete' => 'deleted', 'versioningWS' => true, 'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Registration.svg', ], 'columns' => [ 'attendee' => [ 'label' => 'my_extension.db:registration.attendee', 'config' => [ 'type' => 'group', 'allowed' => 'fe_users', 'minitems' => 1, 'maxitems' => 1, ], ], 'ticket' => [ 'label' => 'my_extension.db:registration.ticket', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'items' => [ ['label' => 'my_extension.db:registration.ticket.regular', 'value' => 'regular'], ['label' => 'my_extension.db:registration.ticket.student', 'value' => 'student'], ['label' => 'my_extension.db:registration.ticket.speaker', 'value' => 'speaker'], ], ], ], ], 'types' => [ '0' => [ 'showitem' => 'attendee, ticket', ], ], ];The table
fe_needs no field for the relation.users Without an attribute such as the role, an intermediate table is not needed: a group or select field with an MM table on the event does the job.
With useCombination, the frontend user itself can be edited inside each registration. Such an edit changes the frontend user everywhere it is used, not only for this conference.
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_sortby']
- Scope
- Display / Proc.
Define a field on the child record that stores the manual sorting information. It is possible to have a different sorting, depending from which side of the relation we look at parent or child.
Attention
Do not confuse this property with foreign_default_sortby. The
foreign_field contains an integer and is managed by the DataHandler. If by accident a content column like "title" is set assortby foreign_, the DataHandler will write these integers into that field, which is most likely not what you want. Usesortby foreign_in this case.default_ sortby This property requires that the foreign_field approach is used.
When using MM relations the field used on the intermediate table is hardcoded to
sorting_. Setting this property has no effect combined with an MM table.foreign Warning
If you use the table only as an inline element, do not put the sortby field in the ctrl section, otherwise TYPO3 CMS will sort the entire table with every update. For example, if you have 10000 records, each with 4 inline elements, TYPO3 CMS will sort 40000 records even if only 4 must be sorted.
-
- Type
- string (table name)
- Required
true
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table']
- Scope
- Display / Proc.
The table name of the child records is defined here. The table must be configured in
$GLOBALS.['TCA']
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_table_field']
- Scope
- Display / Proc.
The
foreign_is the field of the child record pointing to the parent record. This defines where to store the table name of the parent record. On setting this configuration key together with foreign_field, the child record knows what its parent record is – so the child record could also be used on other parent tables. This issue is also known as "weak entity". Do not confuse with foreign_table or foreign_field. It has its own behavior.table_ field
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['foreign_unique']
- Scope
- Display / Proc.
Field which must be unique for all children of a parent record.
A frontend user can register for a conference only once. foreign_
names the field attendee of the registration, so the same frontend user
cannot be selected twice:
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'registrations' => [
'label' => 'my_extension.db:conference.registrations',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_myextension_registration',
'foreign_field' => 'conference',
'foreign_selector' => 'attendee',
'foreign_unique' => 'attendee',
'foreign_match_fields' => [
'status' => 'confirmed',
],
'appearance' => [
'useCombination' => true,
'overwriteCombinationWarningMessage' => 'my_extension.db:conference.registrations.combinationWarning',
],
'overrideChildTca' => [
'columns' => [
'attendee' => [
'config' => [
// The frontend users are stored in the same folder as the conferences
'elementBrowserEntryPoints' => [
'fe_users' => '###CURRENT_PID###',
],
],
],
],
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'--div--;my_extension.db:tab.registrations, registrations',
'',
'before:--div--;my_extension.db:tab.details',
);
-
- Type
- integer > 0
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['maxitems']
- Scope
- Display / Proc.
Maximum number of child items. Defaults to a high value. JavaScript record validation prevents the record from being saved if the limit is not satisfied.
-
- Type
- integer > 0
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['minitems']
- Scope
- Display
Minimum number of child items. Defaults to 0. JavaScript record validation prevents the record from being saved if the limit is not satisfied.
Note
TCA table column fields that define ['config'] can omit the
specification of the intermediate MM table layout in
ext_tables.sql. The TYPO3 database
analyzer takes care of proper schema definition.
-
- Type
- string (table name)
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['MM']
- Scope
- Proc.
This value contains the name of the table in which to store an MM relation. It is used together with foreign_table. The database field with a MM property only stores the number of records in the relation.
Please have a look into the additional information in the MM common property description.
Warning
Copying with MM relations will not create a copy of the value. Thus copying the record
OrgwithOrg->organdA Org->orgasB Newresults inNew->organdA New->orginstead ofB New->newandA New->new. Deleting the relationB New->orgwill result in a broken relationA Org->org.A
-
- Type
- string (field name)
- Scope
- Proc.
If you want to make a MM relation editable from the foreign side (bidirectional) of the relation as well, you need to set
MM_on the foreign side to the field name on the local side.opposite_ field For example, if the field
companies.is your local side and you want to make the same relation editable from the foreign side of the relation in a field calledemployees persons., you would need to set theemployers MM_value of the TCA configuration of theopposite_ field persons.field to the string "employees".employers Note
Bidirectional references only get registered once on the native side in
sys_.refindex
The hotels that a conference recommends are stored in an intermediate table:
The hotels of a conference
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'hotels' => [
'label' => 'my_extension.db:conference.hotels',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_myextension_hotel',
'MM' => 'tx_myextension_conference_hotel_mm',
'appearance' => [
'collapseAll' => true,
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'hotels',
'',
'before:--div--;core.form.tabs:categories',
);
A hotel shows the conferences that recommend it:
The conferences that recommend a hotel
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_hotel', [
'conferences' => [
'label' => 'my_extension.db:hotel.conferences',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_myextension_conference',
'MM' => 'tx_myextension_conference_hotel_mm',
// The other side of the hotels of a conference
'MM_opposite_field' => 'hotels',
'appearance' => [
'collapseAll' => true,
],
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_hotel',
'conferences',
'',
'after:city',
);
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['overrideChildTca']
- Scope
- Display
This property can be used to override certain aspects of the child's TCA if that child record is opened inline of the given parent. Display related TCA properties of the child table can be overridden in
typesandcolumnssection.See also the examples with overrideChildTca.
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['relationship']
- Scope
- Proc.
- Added
- 13.3
Defines whether the field holds one child record or several. This decides which value a Record object provides for this field, for example in a Fluid template.
one,To One manyTo One - The field provides a single
Recordobject, ornullif there is no child record. maxitems is set to1automatically, overriding any other value. oneTo Many - The field provides a
LazyofRecord Collection Recordobjects.
If
relationshipis not set, the field also provides a collection. So does a field with MM, whateverrelationshipsays. Any other value, includingmany, throws an exception unlessTo Many MMis set.maxitemsdoes not change the result the other way round: a field withoutrelationshipstill provides a collection, even ifmaxitemsis1.The organizers answer a comment once. Their reply is a comment, too, so a comment holds one inline comment:
A comment with the reply of the organizers
EXT:my_extension/Configuration/TCA/Overrides/525-tx_myextension_comment-reply.php<?php use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; defined('TYPO3') or die(); ExtensionManagementUtility::addTCAcolumns('tx_myextension_comment', [ 'reply' => [ 'label' => 'my_extension.db:comment.reply', 'config' => [ 'type' => 'inline', // The reply of the organizers is a comment, too. Its parent is the // comment that it answers 'foreign_table' => 'tx_myextension_comment', 'foreign_field' => 'parent', 'foreign_table_field' => 'parent_table', // The organizers answer a comment once 'relationship' => 'oneToOne', 'overrideChildTca' => [ 'types' => [ '0' => [ 'showitem' => 'name, content', ], ], // Only a reply offers the prepared answers 'columns' => [ 'content' => [ 'config' => [ 'valuePicker' => [ 'items' => [ [ 'label' => 'my_extension.db:comment.reply.thanks', 'value' => 'Thank you for your feedback.', ], [ 'label' => 'my_extension.db:comment.reply.recordings', 'value' => 'The recordings are online one week after the conference.', ], ], ], ], ], ], ], ], ], ]); ExtensionManagementUtility::addToAllTCAtypes( 'tx_myextension_comment', 'reply', '', 'after:content', );
-
- Type
- integer
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['size']
- Scope
- Display
Only useful in combination with foreign_selector.
If set to 1 (default), the combination box is a select drop-down, else a select box of given size.
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['symmetric_field']
- Scope
- Display / Proc.
This works like foreign_field, but in case of using bidirectional symmetric relations.
symmetric_defines in which field on the foreign_table the uid of the "other" parent is stored.field
<?php
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
defined('TYPO3') or die();
ExtensionManagementUtility::addTCAcolumns('tx_myextension_conference', [
'partners' => [
'label' => 'my_extension.db:conference.partners',
'config' => [
'type' => 'inline',
'foreign_table' => 'tx_myextension_partnership',
'foreign_field' => 'conference',
'foreign_sortby' => 'conference_sorting',
'foreign_label' => 'partner',
'symmetric_field' => 'partner',
'symmetric_sortby' => 'partner_sorting',
'symmetric_label' => 'conference',
],
],
]);
ExtensionManagementUtility::addToAllTCAtypes(
'tx_myextension_conference',
'partners',
'',
'after:speakers',
);
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['symmetric_label']
- Scope
- Display / Proc.
If set, it overrides the label set in
$GLOBALSfor the inline-view and only if looking to a symmetric relation from the "other" side.['TCA'] [<foreign_ table>] ['ctrl'] ['label']
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['columns'][$field]['config']['symmetric_sortby']
- Scope
- Display / Proc.
This works like foreign_sortby, but in case of using bidirectional symmetric relations. Each side of a symmetric relation could have its own sorting, so
symmetric_defines a field on the foreign_table where the sorting of the "other" side is stored. This property requires that the foreign_field approach is used.sortby
Inline fields and workspaces
Deprecated since version 14.0
Using a workspace-aware parent table with a child table that is not workspace-aware
is deprecated in TYPO3 v14. The automatic TCA migration functionality scans for this
and adds
versioning to affected child tables.
TCA tables that are used as inline child tables in a standard
foreign_table
relationship must be declared workspace-aware if the parent table is workspace-aware.
A typical scenario is inline child tables attached to the
tt_ table as tt_ is workspace-aware by default.
The conferences are workspace-aware:
<?php
return [
'ctrl' => [
'title' => 'my_extension.db:conference',
'label' => 'title',
'descriptionColumn' => 'internal_notes',
'default_sortby' => 'conference_date DESC',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'editlock' => 'editlock',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'translationSource' => 'l10n_source',
'versioningWS' => true,
'origUid' => 't3_origuid',
'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Conference.svg',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
'columns' => [
'title' => [
'label' => 'my_extension.db:conference.title',
'config' => [
'type' => 'input',
'required' => true,
'max' => 255,
'eval' => 'trim',
],
],
'conference_date' => [
'label' => 'my_extension.db:conference.conference_date',
'config' => [
'type' => 'datetime',
'format' => 'date',
'required' => true,
],
],
'internal_notes' => [
'label' => 'my_extension.db:conference.internal_notes',
'config' => [
'type' => 'text',
'rows' => 3,
],
],
],
// The fields of the other tabs are added in Configuration/TCA/Overrides/
'types' => [
'0' => [
'showitem' => '
title, conference_date,
--div--;my_extension.db:tab.program,
--div--;my_extension.db:tab.details,
--div--;core.form.tabs:categories,
--div--;core.form.tabs:access,
hidden, --palette--;;access, fe_group, editlock,
--div--;core.form.tabs:language,
--palette--;;language,
--div--;my_extension.db:tab.comments,
--div--;core.form.tabs:notes,
internal_notes,
',
],
],
'palettes' => [
'access' => [
'label' => 'core.form.palettes:access',
// The labels of the fields tell the editors what the dates are for
'showitem' => '
starttime;my_extension.db:conference.starttime,
endtime;my_extension.db:conference.endtime,
',
],
'language' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
];
If the parent table is workspace-aware, versioningWS
set to true, the child table must also be made workspace-aware. The hotels
are inline children of the conferences:
<?php
return [
'ctrl' => [
'title' => 'my_extension.db:hotel',
'label' => 'name',
'label_alt' => 'city',
'label_alt_force' => true,
'default_sortby' => 'name',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
// Required, as the hotels are inline children of the conferences
'versioningWS' => true,
'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Hotel.svg',
],
'columns' => [
'name' => [
'label' => 'my_extension.db:hotel.name',
'config' => [
'type' => 'input',
'required' => true,
],
],
'city' => [
'label' => 'my_extension.db:hotel.city',
'config' => [
'type' => 'input',
],
],
],
'types' => [
'0' => [
'showitem' => 'name, city',
],
],
];
The same applies if an inline field is used inside a FlexForm field.
Inline fields in content tt_content or on regular pages
If a parent table can be created on regular pages, most commonly when the inline field is
created in table tt_, the child table must also be allowed on regular pages.
Otherwise you will see the following error on saving:
Warning
Attempt to insert record on pages:42 where table "tx_myextension_registration" is not allowed.
To allow the child table on regular pages, set $GLOBALS['TCA'][$table]['ctrl']['security']['ignorePageTypeRestriction'] to true:
<?php
return [
'ctrl' => [
'title' => 'my_extension.db:conference',
'label' => 'title',
'descriptionColumn' => 'internal_notes',
'default_sortby' => 'conference_date DESC',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'editlock' => 'editlock',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'translationSource' => 'l10n_source',
'versioningWS' => true,
'origUid' => 't3_origuid',
'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Conference.svg',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
'columns' => [
'title' => [
'label' => 'my_extension.db:conference.title',
'config' => [
'type' => 'input',
'required' => true,
'max' => 255,
'eval' => 'trim',
],
],
'conference_date' => [
'label' => 'my_extension.db:conference.conference_date',
'config' => [
'type' => 'datetime',
'format' => 'date',
'required' => true,
],
],
'internal_notes' => [
'label' => 'my_extension.db:conference.internal_notes',
'config' => [
'type' => 'text',
'rows' => 3,
],
],
],
// The fields of the other tabs are added in Configuration/TCA/Overrides/
'types' => [
'0' => [
'showitem' => '
title, conference_date,
--div--;my_extension.db:tab.program,
--div--;my_extension.db:tab.details,
--div--;core.form.tabs:categories,
--div--;core.form.tabs:access,
hidden, --palette--;;access, fe_group, editlock,
--div--;core.form.tabs:language,
--palette--;;language,
--div--;my_extension.db:tab.comments,
--div--;core.form.tabs:notes,
internal_notes,
',
],
],
'palettes' => [
'access' => [
'label' => 'core.form.palettes:access',
// The labels of the fields tell the editors what the dates are for
'showitem' => '
starttime;my_extension.db:conference.starttime,
endtime;my_extension.db:conference.endtime,
',
],
'language' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
];
Inline fields on root level tables
If a parent table can be or is always created on root level, the child table has to also be allowed on root level.
An example of this is if you add an inline field to system tables like sys_ or be_.
Set $GLOBALS['TCA'][$table]['ctrl']['rootLevel']
to -1 to allow on both root level and regular pages or set to 1 to allow only on root level.
If regular non-admin backend users need to be able to edit the table, add $GLOBALS['TCA'][$table]['ctrl']['security']['ignoreRootLevelRestriction']
<?php
return [
'ctrl' => [
'title' => 'my_extension.db:location',
'label' => 'name',
'label_alt' => 'city',
'label_alt_force' => true,
'selicon_field' => 'image',
'default_sortby' => 'name',
'rootLevel' => -1,
'security' => [
'ignoreRootLevelRestriction' => true,
],
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Location.svg',
],
'columns' => [
'name' => [
'label' => 'my_extension.db:location.name',
'config' => [
'type' => 'input',
'required' => true,
],
],
'city' => [
'label' => 'my_extension.db:location.city',
'config' => [
'type' => 'input',
],
],
'image' => [
'label' => 'my_extension.db:location.image',
'config' => [
'type' => 'file',
'maxitems' => 1,
'allowed' => 'common-image-types',
'relationship' => 'manyToOne',
],
],
],
'types' => [
'0' => [
'showitem' => 'name, city, image',
],
],
];