Issue Bug Closed

#103480Inline relations: "New button" shown even when "maxitems" is exceeded

Mario Lubenka 03/25/24, 08:37 updated 01/23/25, 11:47

Description

Context

The introduction of the new TCA type “file” brought several refactorings.
During the refactorings, the following line of code was removed:

$config['inline']['inlineNewRelationButtonStyle'] = 'display: none;';

https://github.com/TYPO3/typo3/commit/a7dd022535312710aa050e8b4869ce901a95e002#diff-83816068978280ac4e34f0b1fa37fd72fc57a181f3fe22d78a39fec55895d6baL283

Issue

Now, when using inline relations, the maxitems value is not considered when showing the button. It is now always shown, even when no new records can be added.

Considering this example:

$GLOBALS['TCA']['tt_content']['columns']['myext_field'] = [
    'label' => 'Test',
    'config' => [
        'type' => 'inline',
        'maxitems' => 2,
        'foreign_table' => 'myext_table',
         'foreign_table_field' => 'tablenames',
         'foreign_field' => 'uid_foreign',
         'foreign_label' => 'uid_local',
         'foreign_match_fields' => [
             'fieldname' => 'myext_field'
         ],
        'foreign_selector' => 'uid_local',
        'foreign_sortby' => 'sorting_foreign',
    ]
];

Defining foreign_selector will render the relations view and make the records selectable via the relation wizard.
The “Add relation” button however is no longer hidden, when “maxitems” is reached. This is only the case for the non-relation way.

relation.png

Suggested Fix

Restoring line 282.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.

Files 1

History 2

  1. Georg Ringer commented and changed status New Needs Feedback 06/08/24, 08:44

    I can’t reproduce it with e.g. modifying EXT:news

    'related_links' => [
                'exclude' => true,
                'label' => $ll . 'tx_news_domain_model_news.related_links',
                'config' => [
                    'type' => 'inline',
                    'allowed' => 'tx_news_domain_model_link',
                    'foreign_table' => 'tx_news_domain_model_link',
                    'foreign_sortby' => 'sorting',
                    'foreign_field' => 'parent',
                    'size' => 5,
                    'minitems' => 0,
                    'maxitems' => 2,
                    'appearance' => [
                        'collapseAll' => true,
                        'expandSingle' => true,
                        'levelLinksPosition' => 'bottom',
                        'useSortable' => true,
                        'showPossibleLocalizationRecords' => true,
                        'showAllLocalizationLink' => true,
                        'showSynchronizationLink' => true,
                        'enabledControls' => [
                            'info' => false,
                        ],
                    ],
                    'behaviour' => [
                        'allowLanguageSynchronization' => true,
                    ],
                ],
            ],

    can you retest in latest versions

  2. Oliver Hader commented and changed status Needs Feedback Closed 01/23/25, 11:47

    I also did not manage to reproduce this with recent v13.4.4 with tt_content.image and having maxitems => 1.

    I’m closing this issue. Feel free to reopen the issue, providing additional details how to reproduce the behavior (your TCA configuration, exact TYPO3 version). Thx!