Issue Bug Closed

#92804Sorting of inline records that contain inline records breaks the database

Johannes Schlier 11/09/20, 15:45 updated 02/23/21, 13:13

Description

Sorting inline records (let’s call them ‘parent records’) that contain more inline records (let’s call these ‘children records’) in FormEngine results in a mix of uids of parent and children records that are saved within the database.

This only happens when the child records of a parent record are loaded, i.e. if a parent record is/was opened.
I suspect that the FormEngine JavaScript is responsible for getting the newly sorted uids in the correct order: during this search, the correct field is searched, but the different levels of records are not handled correctly.
_This is my best guess_ as to why the wrong UIDs are passed to the DataHandler.

To reproduce add the following TCA/database definitions (or use the files that I added), add a few records and then re-sort the parent records with one of them being open.

“[…]/Configuration/TCA/tx_test_case.php”:

<?php

return [
    'ctrl' => [
        'title' => 'IRRE sorting test',
        'label' => 'name'
    ],
    'columns' => [
        'name' => [
           'label' => 'Name',
            'config' => [
                'type' => 'input'
            ]
        ],
        'records' => [
            'label' => 'Parent IRRE records',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_test_parent',
                'foreign_sortby' => 'sorting',
                'appearance' => [
                    'useSortable' => true,
                    'enabledControls' => [
                        'sort' => true,
                        'dragdrop' => true
                    ]
                ]
            ]
        ]
    ],
    'types' => [
        0 => [
            'showitem' => 'name,records'
        ]
    ]
];

“[…]/Configuration/TCA/tx_test_parent.php”:

<?php

return [
    'ctrl' => [
        'title' => 'IRRE sorting test parent record',
        'label' => 'name'
    ],
    'columns' => [
        'name' => [
            'label' => 'Name',
            'config' => [
                'type' => 'input'
            ]
        ],
        'children' => [
            'label' => 'Children IRRE records',
            'config' => [
                'type' => 'inline',
                'foreign_table' => 'tx_test_child',
                'foreign_sortby' => 'sorting',
                'appearance' => [
                    'useSortable' => true,
                    'enabledControls' => [
                        'sort' => true,
                        'dragdrop' => true
                    ]
                ],
            ]
        ]
    ],
    'types' => [
        0 => [
            'showitem' => 'name,children'
        ]
    ]
];

“[…]/Configuration/TCA/tx_test_child.php”:

<?php

return [
    'ctrl' => [
        'title' => 'IRRE sorting test child record',
        'label' => 'name'
    ],
    'columns' => [
        'name' => [
            'label' => 'Name',
            'config' => [
                'type' => 'input'
            ]
        ]
    ],
    'types' => [
        0 => [
            'showitem' => 'name'
        ]
    ]
];

“[…]/ext_tables.sql”:

CREATE TABLE `tx_test_case` (
    `name` text,
    `records` text
);

CREATE TABLE `tx_test_parent` (
    `name` text,
    `children` text,
    `sorting` int(11) default 0 not null
);

CREATE TABLE `tx_test_child` (
    `name` text,
    `sorting` int(11) default 0 not null
);

Reviews 2