MM

MM
Type:string (table name)
Scope:Proc.
Types:group, select, inline

The relation of the records of the specified table gets stored in an intermediate table. The name of this table is stored in the property MM.

This property is used with foreign_table (select) for select fields, allowed (group) for group fields or foreign_table (inline) for inline fields.

The table defined in this property is automatically created by the Database Analyzer starting with v11.4.

The field for which an MM configuration exists stores the number of records in the relation on each update, so the field should be an integer.

Note

Using MM relations you can only store the relations for foreign tables in the list. You cannot add properties like string values for the relation itself.

MM relations and FlexForms

MM relations has been tested to work with FlexForms if not in a repeated element in a section.

Auto creation of intermediate MM tables from TCA

New in version 11.4: Starting with v11.4 intermediate mm tables defined in ['config']['MM'] are created automatically and do not have to be defined in file:ext_tables.sql anymore.

TCA table column fields that define ['config']['MM'] can drop specification of the intermediate mm table layout in: file:ext_tables.sql. The TYPO3 database analyzer takes care of proper schema definition.

Extensions are strongly encouraged to drop ext_tables.sql CREATE TABLE definitions for those intermediate tables referenced by TCA table columns. Dropping these definitions allows the Core to adapt and migrate definitions if needed.

The mm tables are automatically created if:

  • A table column TCA config defines MM with type='select', type='group' or type='inline'.
  • The “MM” intermediate table has no TCA table definition (!).
  • A table of the resulting name is not defined in ext_tables.sql.

The schema analyzer takes care of further possible fields apart from uid_local and uid_foreign, like sorting, sorting_foreign, tablenames, fieldname and uid if necessary, depending on “local” side of the TCA definition.

Example

The “local” side of a mm table is defined as such in TCA:

...
'columns' => [
    ...
    'myField' => [
        'label' => 'myField',
        'config' => [
            'type' => 'group',
            'foreign_table' => 'tx_myextension_myfield_child',
            'MM' => 'tx_myextension_myfield_mm',
        ]
    ],
    ...
],
...

A table like the following will be automatically created in the Database Analyzer:

CREATE TABLE tx_myextension_myfield_mm (
    uid_local int(11) DEFAULT '0' NOT NULL,
    uid_foreign int(11) DEFAULT '0' NOT NULL,
    sorting int(11) DEFAULT '0' NOT NULL,

    KEY uid_local (uid_local),
    KEY uid_foreign (uid_foreign)
);

Columns of the intermediate MM table

The intermediate table has three columns as a minimum:

uid_local, uid_foreign (Required)
Storing uids of both sides. If done right, this is reflected in the table name - tx_foo_local_foreign_mm
sorting (Required)
Is a required field used for ordering the items.
sorting_foreign
Is required if the relation is bidirectional (see description and example below table)
tablenames
Is used if multiple tables are allowed in the relation.
uid (auto-incremented and PRIMARY KEY)
May be used if you need the “multiple” feature (which allows the same record to be references multiple times in the box. See MM_hasUidField for type=’select’ and MM_hasUidField for type=’group’ fields.
further fields
May exist, in particular if MM_match_fields / MM_match_fields is involved in the set up.