Auto-created columns from 'ctrl'

New in version 13.3

Certain ctrl settings, such as the enablecolumns and languageField settings require TCA columns definitions.

Load order when building TCA

To understand if and when TCA column auto-creation from ctrl definitions kicks in, it is important to have an overview of the order of the single loading steps:

  1. Load single files from extension Configuration/TCA files
  2. NEW - Enrich columns from ctrl settings
  3. Load single files from extension Configuration/TCA/Overrides files
  4. Apply TCA migrations
  5. Apply TCA preparations

As a result of this strategy, columns fields are not auto-created, when a ctrl capability is added in a Configuration/TCA/Overrides file, and not in a Configuration/TCA "base" file. In general, such capabilities should be set in base files only: Adding them at a later point - for example in a different extension - is brittle and there is a risk the main extension can not deal with such an added capability properly.

Overriding definitions from auto-created TCA columns

In most cases, developers do not need to change definitions of columns auto-created by the Core. In general, it is advisable to not actively do this. Developers who still want to change detail properties of such columns should generally stick to "display" related details only.

There are two options to have own definitions: When a column is already defined in a "base" TCA file (Configuration/TCA), the Core will not override it. Alternatively, a developer can decide to let the Core auto-create a column, to then override single properties in Configuration/TCA/Overrides files.

As example, "base" pages file defines this (step 1 above):

EXT:core/Configuration/TCA/pages.php (Excerpt)
<?php

return [
    'ctrl' => [
        'enablecolumns' => [
            'disabled' => 'disabled',
        ],
    ],
    // ...
];
Copied!

The Core thus creates this columns definition (step 2 above):

Column entries created by the Core
<?php

$GLOBALS['TCA']['pages']['columns']['disabled'] = [
    'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.enabled',
    'exclude' => true,
    'config' => [
        'type' => 'check',
        'renderType' => 'checkboxToggle',
        'default' => 0,
        'items' => [
            [
                'label' => '',
                'invertStateDisplay' => true,
            ],
        ],
    ],
];
Copied!

When an editor creates a new page, it should be "disabled" by default to avoid having a new page online in the website before it is set up completely. A Configuration/TCA/Overrides/pages.php file does this:

EXT:my_extension/Configuration/TCA/Overrides/pages.php
<?php

// New pages are disabled by default
$GLOBALS['TCA']['pages']['columns']['disabled']['config']['default'] = 1;
Copied!