Feature: #104814 - Automatically add system fields to content types

See forge#104814

Description

All content elements types ( CType) are usually equipped with the same system fields (language, hidden, etc.) - see also Feature: #104311 - Auto created system TCA columns. Adding them to the editor form has previously been done by adding those fields to each content types' showitem definition.

In the effort to simplify content element creation, to unify the available fields and position for the editor and to finally reduce configuration effort for integrators, those system fields are now added automatically based on the ctrl definition.

The following tabs / palettes are now added automatically:

  • The General tab with the general palette at the very beginning
  • The Language tab with the language palette after custom fields
  • The Access tab with the hidden and access palettes
  • The Notes tab with the rowDescription field

As mentioned, in case one of those palettes has been changed to no longer include the corresponding system fields, those fields are added individually depending on their definition in the table's ctrl section:

  • The ctrl[type] field (usually CType)
  • The colPos field
  • The ctrl[languageField] (usually sys_language_uid)
  • The ctrl[editlock] field (usually editlock)
  • The ctrl[enablecolumns][disabled] field (usually hidden)
  • The ctrl[enablecolumns][starttime] field (usually starttime)
  • The ctrl[enablecolumns][endtime] field (usually endtime)
  • The ctrl[enablecolumns][fe_group] field (usually fe_group)
  • The ctrl[descriptionColumn] field (usually rowDescription)

By default, all custom fields - the ones still defined in showitem - are added after the general palette and are therefore added to the General tab, unless a custom tab (e.g. Plugin, or Categories) is defined in between. It is also possible to start with a custom tab by defining a --div-- as the first item in the showitem. In this case, the General tab will be omitted.

All those system fields, which are added based on the ctrl section are also automatically removed from any custom palette and from the customized type's showitem definition.

If the content element defines the Extended tab, it will be inserted at the end, including all fields added to the type via API methods, without specifying a position, e.g. via ExtensionManagementUtility::addToAllTcaTypes().

Impact

Creating content elements has been simplified by removing the need to define the system fields for each element again and again. This shrinks down a content element's showitem to just the element specific fields.

A usual migration will therefore look like the following:

Before:

'slider' => [
    'showitem' => '
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,
            --palette--;;general,
            --palette--;;headers,
            slider_elements,
            bodytext;LLL:EXT:awesome_slider/Resources/Private/Language/locallang_ttc.xlf:bodytext.ALT.slider_description,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:appearance,
            --palette--;;frames,
            --palette--;;appearanceLinks,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,
            --palette--;;language,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,
            --palette--;;hidden,
            --palette--;;access,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
            categories,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,
            rowDescription,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
    ',
],
Copied!

After:

'slider' => [
    'showitem' => '
            --palette--;;headers,
            slider_elements,
            bodytext;LLL:EXT:awesome_slider/Resources/Private/Language/locallang_ttc.xlf:bodytext.ALT.slider_description,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,
            categories,
        --div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended,
    ',
],
Copied!

Since all fields, palettes and tabs, which are defined in the showitem are added after the general palette, also the Categories tab - if defined - is displayed before the system tabs / fields. The only special case is the Extended tab, which is always added at the end.