phptypo3fluidtypo3-9.xfluid-styled-content

'Unknown column' error when adding custom fields in TYPO3?


I am trying to add two new fields to the header area of all the content elements, but when I try to save the element with text in those fields I get this error:

An exception occurred while executing 'SELECT `ext_field1` FROM `tt_content` WHERE `uid` = ?' with params [27]: Unknown column 'ext_field1' in 'field list'

My ext_tables.sql is like this:

CREATE TABLE tt_content (
    ext_field1 varchar(22) DEFAULT '' NOT NULL,
    ext_field2 varchar(22) DEFAULT '' NOT NULL,
);

My tt_content.php is like this:

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', [
    'ext_field1' => [
        'exclude' => 0,
        'label' => 'Label 1',
        'config' => [
            'type' => 'input',
        ],
    ],
    'ext_field2' => [
        'exclude' => 0,
        'label' => 'Label 2',
        'config' => [
            'type' => 'input',
        ],
    ],
]);

\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
    'tt_content',
    'headers',
    '--linebreak--,ext_field1,ext_field2',
    'after:header_link'
);

Solution

  • It looks like your columns are not in the database. Solution: