In my extension I have two models team members (parent) and expertise (child). The bidirectional relationsship between the two models is stored in an intermediate table. This works fine bit there is one problem.
When I edit the team member record in the TYPO3 Backend and assign an expertise record to it and then open the corresponding expertise record, the newly assigend team member record is shown at the top of the list instead of at the end. The problem also occurs the other way around.
This is because the sorting respectively sorting_foreign field in the intermediate table is set to its default value (0) when the record is saved.
How can I fix this?
TCA for model team member:
...
'expertise' => [
'label' => 'Expertise',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_btp_domain_model_expertise',
'foreign_table_where' => 'ORDER BY tx_btp_domain_model_expertise.title',
'MM' => 'tx_btp_team_expertise_mm',
'maxitems' => 50,
],
],
...
TCA for model expertise:
...
'team' => [
'label' => 'Team',
'config' => [
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'foreign_table' => 'tx_btp_domain_model_team',
'MM' => 'tx_btp_team_expertise_mm',
'MM_opposite_field' => 'expertise',
'maxitems' => 50,
],
],
...
Intermediate table definition:
CREATE TABLE tx_btp_team_expertise_mm (
uid_local int(11) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(11) unsigned DEFAULT '0' NOT NULL,
sorting int(11) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(11) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);