sys_file_metadata table extended but field not showing

251 views Asked by At

I have extended the sys_file_metadata table by adding one additional column. Newly entered column is present in the table, but the field is not showing in flexform. Am I missing something?

1

There are 1 answers

0
René Pflamm On BEST ANSWER

You have to add you field to the TCA colums and to the showitem:

<?php

use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;

defined('TYPO3_MODE') || die();

$tempColumns = [
    'protected_file' => [
        'exclude' => true,
        'label'   => 'LLL:EXT:spt_downloads/Resources/Private/Language/locallang_db.xlf:tx_sptdownloads_domain_model_downloadmanager.protected_file',
        'config'  => [
            'type'    => 'check',
            'items'   => [
                '1' => [
                    '0' => 'LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.enabled'
                ]
            ],
            'default' => 0,
        ]
    ]
];

ExtensionManagementUtility::addTCAcolumns('sys_file_metadata', $tempColumns);
ExtensionManagementUtility::addToAllTCAtypes('sys_file_metadata', 'protected_file');

It's important not to forget the addTCAcolumns and addToAllTCAtypes. The first one add your field to the TCA and the second one make the field visible into the editor of your element by puttin it into showitem of the tca.

You have also put this code into spt_downloads/Configuration/TCA/Overrides/sys_file_metadata.php. The use of this code in an ext_tables.php is deprecated and dont work anymore.