Examples

Required type - minimal configuration

The type 0 is required to be defined. It has to have at least the property showitem defined. A minimal configuration can be seen here, for example:

EXT:styleguide/Configuration/TCA/tx_styleguide_ctrl_minimal.php
[
    'types' => [
        [
            'showitem' => 'title',
        ],
    ],
]
Copied!

It displays nothing but a single field.

Required type - tabs and palettes

The following configuration specifies two tabs: the first one labelled "general" with three fields "category" "subject" and "message", and the second one labelled "access" with the field "personal". Only the default type "0" is specified. Opening such a record looks like this:

A common example of the control section

Optional additional types

The power of the "types" configuration becomes clear when you want the form composition of a record to depend on a value from the record. Let's look at the tx_styleguide_type table from the styleguide extension. The ctrl section of its TCA contains a property called :php: type:

EXT:styleguide/Configuration/TCA/tx_styleguide_type.php
[
    'ctrl' => [
        'title' => 'Form engine - type',
        'label' => 'input_1',
        'tstamp' => 'tstamp',
        'crdate' => 'crdate',
        'cruser_id' => 'cruser_id',
        'delete' => 'deleted',
        'sortby' => 'sorting',
        'iconfile' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
        'versioningWS' => true,
        'origUid' => 't3_origuid',
        'languageField' => 'sys_language_uid',
        'transOrigPointerField' => 'l10n_parent',
        'transOrigDiffSourceField' => 'l10n_diffsource',
        'translationSource' => 'l10n_source',
        'enablecolumns' => [
            'disabled' => 'hidden',
        ],
        'type' => 'record_type',
    ],
]
Copied!

This indicates that the field called record_type is to specify the type of any given record of the table. Let's look at how this field is defined in the property columns:

EXT:styleguide/Configuration/TCA/tx_styleguide_type.php
[
    'columns' => [
        'record_type' => [
            'label' => 'type',
            'config' => [
                'type' => 'select',
                'renderType' => 'selectSingle',
                'items' => [
                    [
                        'type 0',
                        '0',
                    ],
                    [
                        'Type with changed fields',
                        'withChangedFields',
                    ],
                    [
                        'Type with columnsOverrides',
                        'withColumnsOverrides',
                    ],
                ],
            ],
        ],
    ],
]
Copied!

There's nothing unusual here. It's a pretty straightforward select field, with three options. Finally, in the types section, we define what fields should appear and in what order for every value of the type field:

EXT:styleguide/Configuration/TCA/tx_styleguide_type.php
[
    'types' => [
        0 => [
            'showitem' => 'record_type, input_1, text_1',
        ],
        'withChangedFields' => [
            'showitem' => 'record_type, input_1, input_2, text_1',
        ],
        'withColumnsOverrides' => [
            'showitem' => 'record_type, input_1, input_2, text_1',
            'columnsOverrides' => [
                'input_2' => [
                    'label' => 'input_2, readOnly, size=10, empty renderType',
                    'config' => [
                        'renderType' => '',
                        'readOnly' => true,
                        'size' => 10,
                    ],
                ],
                'text_1' => [
                    'config' => [
                        'renderType' => 't3editor',
                        'format' => 'html',
                    ],
                ],
            ],
        ],
    ],
]
Copied!

The result if the following display when type 0 is chosen:

Changing to type withChangedFields reloads the form and displays the a different set of fields:

And finally, type withOverriddenColumns shows the fields and overrides part of the configuration of the fields: