Issue Bug Closed

#103825Undefined array key "foreign_table" in TcaInputPlaceholders

Robert Vock 05/13/24, 09:56 updated 07/09/24, 15:35

Description

When you’re using a select field as placeholder for a textfield in TCA, you get an Undefined array key “foreign_table” in TcaInputPlaceholders warning in PHP 8.

TCA:

$GLOBALS['TCA']['tt_content']['columns']['fieldname'] = [
    'label' => 'Fieldlabel',
    'config' => [
        'type' => 'input',
        'eval' => 'trim',
        'placeholder' => '__row|CType',
    ],
];

Relevant Code-Position:
https://github.com/TYPO3/typo3/blob/2acd0592d211663ba3d29cb2aafe1344d04f9f0b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaInputPlaceholders.php#L123

switch ($fieldConfig['type']) {
    case 'select':
    case 'category':
        // The FormDataProviders already resolved the select items to an array of uids,
        // filter out empty values that occur when no related record has been selected.
        $possibleUids = array_filter($value);
        $foreignTableName = $fieldConfig['foreign_table'];
        break;

It’s not guaranteed, that the foreign_table key is set for all select types.

Reviews 3

History 26

  1. Gerrit Code Review pushed patch set 1 for main to change 84391 status New Under Review 05/25/24, 08:53

  2. Gerrit Code Review pushed patch set 2 for main to change 84391 05/25/24, 10:05

  3. Gerrit Code Review pushed patch set 1 for 11.5 to change 84394 05/25/24, 10:06

  4. Gerrit Code Review pushed patch set 1 for 12.4 to change 84395 05/25/24, 10:06

  5. Georg Ringer commented and changed status Under Review Resolved done 0 % 100 % 05/25/24, 10:25

    Applied in changeset commit:a2d9e7dc24f92dae2f8194316499d9d206355990.

  6. Benni Mack changed status Resolved Closed 07/09/24, 15:35