Parent-Child Relations and IRRE
Data Model describes which fields exist and what each one means.
This page describes how those fields are kept consistent while editors
work: TYPO3's IRRE (Inline Relational Record Editing) infrastructure on
the backend-editing side, and the Data hook pipeline that
runs on every save, move, copy, and delete.
IRRE in TYPO3, briefly
IRRE is TYPO3 Core's mechanism for editing a one-to-many relation
inline, inside the parent record's own edit form. With
foreign_ and foreign_, the relation is stored
directly through a field on the child record rather than through an
intermediate MM table. A TCA field of type => inline with
foreign_ and foreign_ tells FormEngine: this
parent's children are whichever rows in foreign_ have
foreign_ pointing back at this record's uid.
Grid Elements uses exactly this configuration, and nothing more exotic.
tx_ is that inline field, with
foreign_ and
foreign_. This matters
architecturally, because it means the backend editing widget and the
frontend data-fetching path described in Nesting resolve a
container's children through the same underlying relation. There is no
separate storage format for "children as edited in the backend" versus
"children as rendered on the frontend".
Backend editing behavior
A few TCA settings on tx_ shape how the inline
widget behaves, worth naming because they explain what an editor sees:
appearance.disables the widget's ownenabled Controls newanddragdropcontrols. Children are not created by clicking "new" inside the container's form, they are created through the New Content Element wizard or dragged in from the page module (Web > Page on TYPO3 13, Content > Layout on TYPO3 14), both of which writetx_directly.gridelements_ container overridedefaults a newly inline-created child'sChild Tca coltoPos -1, matching the sentinel described on Data Model.foreign_means children use the ordinarysortby = sorting tt_sorting field. There is no separate Grid Elements sort order to keep in sync.content
The DataHandler pipeline
Persistent consistency is not left to TCA and IRRE alone. Grid Elements
hooks into TYPO3's Data at three points, routed through
Classes/ and implemented in
Classes/:
| Hook | Responsibility |
|---|---|
process
(Pre) | Runs before a tt_/pages save is persisted. Keeps
col, tx_ and
tx_ consistent with each other, guards
against container cycles and dangerous shortcut references
before they can be written, and keeps a child's language in
sync with its container's language. |
process
(After) | Runs after the save. Unless automatic unused-column correction
has been disabled in the extension configuration, it
re-evaluates affected elements against a changed grid or
backend layout, moving elements to or from the "unused
elements" state described on Data Model, and propagates
relation changes to translated copies via
check. |
process (Process) | Runs on copy/move commands. Implements "Paste as Reference" by
creating a CType = shortcut record instead of duplicating
content, and keeps container child counts in sync on copy, move
and delete. |
A separate pair of hooks, process and
process, gate these same operations against a
column's allowed/disallowed/maxitems configuration before any of the
above runs. That is a restriction-enforcement concern, not a
relation-consistency one, and is described on Restrictions, Validation & Permissions.
Keeping counts and translations in sync
Whenever a save or command changes which container an element belongs
to, Abstract adjusts the
affected containers' tx_ counters (see
Data Model for what that counter means). It is called from the
preprocessing and command-map handling paths as needed when children
are moved, copied, attached or detached.
Translations need their own synchronization, because IRRE's
foreign_ relation does not automatically re-parent a
translated child to a translated container. check
propagates a container or child's relation change to its translated
counterparts, re-pointing them at the matching container in their own
language where one exists, and clearing the relation where it does
not, rather than leaving a translated child silently attached to a
different language's container.
Cycle protection
A container becoming its own direct or indirect container would make
both backend editing and frontend rendering recurse forever.
Classes/ prevents this at two points:
- Direct or indirect self-reference.
getwalksContainer Ancestor Chain () tx_upward from a candidate container to the root, andgridelements_ container wouldrejects an assignment that would place a container inside its own ancestor chain. This runs both on a direct field edit (Create Container Cycle () Pre) and on a drag-and-drop or cut/paste move (Process Field Array:: set Field Entries () Hooks\).Data Handler:: process Cmdmap_ before Start () - Shortcut references into an ancestor. A
CType = shortcutelement referencing one of its own current or prospective ancestor containers would create the same kind of rendering loop indirectly.shortcutprotects individual shortcut edits and moves. When an entire Grid Element subtree is relocated,References Forbidden Container () subtreescans its descendants for shortcut references that would become cyclic in the new ancestor chain.References Forbidden Container ()
A blocked cmdmap operation is rejected and removed from the command map. During direct datamap editing, the offending relation or reference fields are removed from the incoming field array so the invalid relationship cannot be persisted. In both cases a flash message is shown to the editor.