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:
[
'types' => [
[
'showitem' => 'title',
],
],
]
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:

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
:
[
'ctrl' => [
'title' => 'Form engine - type',
'label' => 'input_1',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'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',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
]
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
:
[
'columns' => [
'record_type' => [
'label' => 'type',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
[
'label' => 'type 0',
'value' => '0',
],
[
'label' => 'Type with changed fields',
'value' => 'withChangedFields',
],
[
'label' => 'Type with columnsOverrides',
'value' => 'withColumnsOverrides',
],
],
],
],
],
]
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:
[
'types' => [
0 => [
'showitem' => 'record_type, input_1, text_1',
],
'withChangedFields' => [
'showitem' => 'record_type, input_1, color_1, text_1',
],
'withColumnsOverrides' => [
'showitem' => 'record_type, input_1, color_1, text_1',
'columnsOverrides' => [
'color_1' => [
'label' => 'color_1, readOnly, size=10',
'config' => [
'readOnly' => true,
'size' => 10,
],
],
'text_1' => [
'config' => [
'renderType' => 't3editor',
'format' => 'html',
],
],
],
],
],
]
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:

Note
It is a good idea to give all "types" speaking names, except the default
type 0
. Therefore we named the other types withChangedFields
and withOverriddenColumns
instead of 1, 2 etc. In a real life example
they should have names from the domain.