[TYPO3-mvc] Cannot update mm-relation (missing tablenames)

Kevin Ulrich Moschallski km at 3digit.de
Sun Nov 14 00:11:14 CET 2010


Hi Jochen,

i applied your patch and the tablenames field is filled with the name of the child table. I'm not quite sure about this because it's not well documented, but as far is i saw in some examples the value for tablenames isn't the child table name. It is the name of the parent table. Please have a look here:

http://buzz.typo3.org/teams/core/article/bidirection-mm-relations/

Let me first post my current TCA for better understanding:

Parent table:

'items' => array(
			'exclude' => 0,
			'label'   => 'LLL:EXT:specialoffers_mvc/Resources/Private/Language/locallang_db.xml:tx_specialoffersmvc_domain_model_portal.items',
			'config'  => array(
                                'type' => 'group',
                                'internal_type' => 'db',
                                'allowed' => 'tx_specialoffersmvc_domain_model_item',
                                'foreign_table' => 'tx_specialoffersmvc_domain_model_item',
                                'MM_opposite_field' => 'portals',
                                'MM' => 'tx_specialoffersmvc_portal_item_mm',
                                'MM_match_fields' => array(
                                    'tablenames' => 'tx_specialoffersmvc_domain_model_portal'
                                ),
                                'size' => 5,
                                'maxitems' => 9999
			)
		),

Child table:

'portals' => array(
			'exclude' => 0,
			'label'   => 'LLL:EXT:specialoffers_mvc/Resources/Private/Language/locallang_db.xml:tx_specialoffersmvc_domain_model_item.portals',
			'config'  => array(
                                'type' => 'group',
                                'internal_type' => 'db',
                                'allowed' => 'tx_specialoffersmvc_domain_model_portal',
                                'MM_match_fields' => array('tablenames' => 'tx_specialoffersmvc_domain_model_portal'),
                                'foreign_table' => 'tx_specialoffersmvc_domain_model_portal',
                                'foreign_field' => 'items',
                                'prepend_tname' => 1,
                                'size' => 5,
                                'maxitems' => 9999,
                                'MM' => 'tx_specialoffersmvc_portal_item_mm',
			)
		),

When i now add relations on the backend the value of tablenames is set to tx_specialoffersmvc_domain_model_portal from both sides. When i now add a relation with extbase all my relations are overwritten and the value for tablenames becomes tx_specialoffersmvc_domain_model_item like the code suggest:

$row[$columnMap->getRelationTableRelatedTableColumnName()] = $columnMap->getChildTableName();

I tried to get the tablename from MM_match_fields:

if ($columnMap->getRelationTableRelatedTableColumnName() !== NULL && $columnMap->getChildTableName() !== NULL && array_key_exists($columnMap->getRelationTableRelatedTableColumnName(), $columnMap->getRelationTableMatchFields())) {
                        $arrayMatchFields = $columnMap->getRelationTableMatchFields();
                        $row[$columnMap->getRelationTableRelatedTableColumnName()] = $arrayMatchFields[$columnMap->getRelationTableRelatedTableColumnName()];
		}

I can see in my sql log that the relation is inserted correct but after that a delete query removes it.

Do you have an idea why this happens or maybe you have a better approach.

It's late now and i will continue tomorrow with this issue, also with increase and decrease the other side of the relation when mm_opposite_field is set.

Regards,

Kevin
Am 13.11.2010 um 23:09 schrieb Jochen Rau:

> Hi.
> 
>> I have opened an Issue and scheduled it for 1.3.0beta2.
>> 
>> http://forge.typo3.org/issues/10770
> 
> ... and attached a patch. Please test and give feedback.
> 
> Regards
> Jochen
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list