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) forgroup
fields or foreign_table (inline) forinline
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']
are created automatically and do not have to be defined in
ext_
anymore.
TCA table column fields that define ['config']
can
drop specification of the intermediate mm table layout in:
ext_
. The TYPO3 database analyzer
takes care of proper schema definition.
Extensions are strongly encouraged to drop ext_
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
withtype='select'
,type='group'
ortype='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_
and uid_
, like tablenames
,
fieldname
and uid
if necessary, depending on local side of the
TCA definition.
The fields used for sorting sorting
and sorting_
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',
]
],
...
],
...
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)
);
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.