Search code examples
phptypo3typo3-8.xdbaltypo3-extensions

TYPO3 8.7 TCA Select on own Table


We have a problem with a select which is defined in TCA after a core update from TYPO3 6.2 LTS to 8.7 LTS.

The problem is, that the select uses all available memory. I think, that the problem is caused by the fact, that the select in TCA selects the own table and we have a loop now.

In TYPO3 6.2 the select has worked as expected.

Can someone confirm this behavior or has a solution for this?

Best Regards

Markus Gehrig

File Configuration/TCA/Override/tt_address.php:

'tx_twwcprojectmanager_company' => array(
    'exclude' => 0,
    'label' => 'LLL:EXT:twwc_projectmanager/Resources/Private/Language/locallang_db.xlf:tx_twwcprojectmanager_domain_model_company.tx_twwcprojectmanager_company',
    'config' => array(
        'type' => 'select',
        'items' => array(
            array('LLL:EXT:twwc_projectmanager/Resources/Private/Language/locallang_db.xlf:tt_address.tx_twwczusatzprojekte_nochoice', 0),
        ),
        'foreign_table' => 'tt_address',
        'foreign_table_where' => 'ORDER BY company',
        'minitems' => 0,
        'maxitems' => 1,
    ),
),

Solution

  • You have to exclude the element's uid in your foreign_table_where string:

    'foreign_table_where' => ' AND tt_address.uid != ###THIS_UID### ORDER BY tt_address.company'
    

    There are several other markers you could use in a similar context: https://docs.typo3.org/typo3cms/TCAReference/8.7/ColumnsConfig/Type/Select.html#foreign-table-where