Creating MM relations in a group field with a translatable table causes translated records to show up twice
I have the following problem:
I have two tables, for example project and person.
These two are connected using the TYPO3 'MM' relation type.
The person table has the following TCA definition:
'projects_lead' => [ 'l10n_mode' => 'exclude', 'config' => [ 'type' => 'select', 'renderType' => 'selectMultipleSideBySide', 'foreign_table' => 'tx_example_domain_model_project', 'foreign_table_where' => 'tx_example_domain_model_project.sys_language_uid=0', 'MM' => 'tx_example_mm_person_project', 'MM_match_fields' => [ 'type' => 1 ] ] ]
This all works as expected.
The definition for the projects is the following:
'lead' => [ 'l10n_mode' => 'exclude', 'config' => [ 'type' => 'group', 'internal_type' => 'db', 'allowed' => 'tx_example_domain_model_person', 'MM' => 'tx_example_mm_person_project', 'MM_opposite_field' => 'projects_lead', 'MM_match_fields' => [ 'type' => 1 ], 'suggestOptions' => [ 'tx_example_domain_model_person' => [ 'searchCondition' => 'sys_language_uid=0' ], ] ] ]
For this side I use the group type so TYPO3 does not load all available people into the select (if there's a lot of them this is not really desired) and to use the nice search as you type box.
In my case, there is also a type match to allow people to be connected with different positions (as lead for example), but this shouldn't have any effect on the behaviour.
From the person side of the relation everything works as expected but from the project side I now face the following problem:
When searching for a person using the suggest wizard everything works fine, I only get the default language version of people.
When adding a person that has a translation, TYPO3 creates duplicated relations within the mm table for the translation.
This is fine, but upon opening the record TYPO3 now sees two relations, one to the default language person and one to the translated person.
In my opinion and case, the translation should not show up as it only confuses editors. Seeing the same name twice makes you think there are duplicates when, in this case, there actually aren't.
Of course this is a bit more complex if the relations fields can differ for translations.
Maybe we could check both sides for their 'l10n_mode' setting. If a translation of a person can have different relations, it would be correct to show both versions of the person.
Since both sides are set to 'l10n_mode' => 'exclude', this behaviour is not quite as expected and wanted.
The select element does handle this correctly - maybe through the 'foreign_table_where'.
The group element unfortunately does not offer a similar functionality, but this should be considered as a use case to catch.