[TYPO3-mvc] MM (many to many) how to tca.php

Franz Koch typo3.RemoveForMessage at elements-net.de
Fri Apr 30 17:21:06 CEST 2010


Hey Cornelius,

> TCA.php
> ================================
> 'columns' => array(
> 'countries' => array(
> 'config' => array (
> 'type' => 'inline',
> 'foreign_class' => 'Tx_xx_Domain_Model_Staat',
> 'foreign_table' => 'tx_xx_domain_model_staat',
> 'MM' => 'tx_xx_domain_model_unternehmen_staat_mm',
> 'MM_match_fields' => array(
> "nr" => 'tx_xx_domain_model_staat',
> "unternehmen_nr" => 'tx_xx_domain_model_unternehmen'
> ),
>
> )
> ),
> ================================

Please have a look at the TYPO3 documentation [1] for how to 
configure/use MM_match_fields - it seems like you've got a wrong picture 
from it.

With MM_match_fields and MM_insert_fields (you need both) you can tell 
TYPO3 which additional data should be stored in the MM table in order to 
identify the relations to different tables as soon as you use one MM 
table for relations to multiple other tables (like DAM does).
It does not insert values from fields or objects there, but simply the 
plain text value you defined in your configuration. So having this 
configuration:

> 'MM_match_fields' => array(
>    "nr" => 'tx_xx_domain_model_staat',
>    "unternehmen_nr" => 'tx_xx_domain_model_unternehmen'
> ),

Typo3 will look for MM relations, where the MM table has the value 
"tx_xx_domain_model_staat" in it's field "nr" and the value 
"tx_xx_domain_model_unternehmen" in it's field "unternehmen_r". As long 
as you don't add those values via MM_insert_fields, your quieries will 
alway return a empty result. The SQL definition of your MM table would 
have to look like this:

CREATE TABLE tx_xx_domain_model_unternehmen_staat_mm (
	uid_local...,
	uid_foreign...,
	nr...,
	unternehmen_nr...,
	sorting
);


But as it seems, you're only using the MM-table for a relation between 2 
tables, so simply drop the "MM_match_field" part in your TCA 
configuration and everything should work as expected.



[1] 
http://typo3.org/documentation/document-library/core-documentation/doc_core_api/4.3.0/view/4/2/#id2522688 
(scroll down to the MM part)
-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list