MM

MM

MM
Type
string (table name)
Path
$GLOBALS['TCA'][$table]['columns'][$field]['config']
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.

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 ext_tables.sql anymore.

TCA table column fields that define ['config']['MM'] can drop specification of the intermediate mm table layout in: 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 tablenames, fieldname and uid if necessary, depending on local side of the TCA definition.

The fields used for sorting sorting and sorting_foreign are always created, they do not need to be defined in TCA.

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',
        ]
    ],
    ...
],
...
Copied!

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,
    sorting_foreign int(11) DEFAULT '0' NOT NULL,

    KEY uid_local (uid_local),
    KEY uid_foreign (uid_foreign)
);
Copied!

Columns of the intermediate MM table

The intermediate table may have the following fields:

uid_local, uid_foreign
Storing uids of both sides. If done right, this is reflected in the table name - tx_foo_local_foreign_mm
sorting, sorting_foreign
Are required fields used for ordering the items.
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='group' fields.
further fields
May exist, in particular if MM_match_fields / MM_match_fields is involved in the set up.