Record types

type
Type:string (field name)
Scope:Display / Proc.

Field name, which defines the “record type”.

The value of this field determines which one of the types configurations are used for displaying the fields in the FormEngine. It will probably also affect how the record is used in the context where it belongs.

The most widely known usage of this feature is the case of Content Elements where the Type: selector is defined as the “CType” field and when you change that selector you will also get another rendering of the form:

The type selector of a content elements

The type selector of a content elements

It is used for example by the “doktype” field in the “pages” table.

On changing the value of the field defined in type the user gets prompted to reload the record.

The record needs to be reloaded to show the changed fields.

The record needs to be reloaded to show the changed fields.

Only one type field can be defined. If you need to reload the record on changing another field, see property onchange.

It is also possible to make the type depend on the value of a related record, for example to switch using the type field of a foreign table. The syntax is relation_field:foreign_type_field. For example the sys_file_metadata table takes its type from the sys_file table.

Examples

the type stored in a field

The record with default type `0`

The record with default type 0

The table :sql:`` table from the “examples” extension defines different types. The field used for differentiating the types is the “record_type” field. Hence we have the following in the ['ctrl'] section of the tx_examples_dummy table:

   'ctrl' => [ 
      'title' => 'Form engine - type',
      'label' => 'uid',
      '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' => 'type',
   ],

The “record_type” field can take values ranging from 0 to 2. Accordingly we define types for the same values. Each type defines which fields will be displayed in the BE form:

   'types' => [ 
      '0' => [ 
         'showitem' => 'type, text_1',
      ],
      'test' => [ 
         'showitem' => 'type, text_1',
         'columnsOverrides' => [ 
            'text_1' => [ 
               'config' => [ 
                  'renderType' => 't3editor',
                  'format' => 'html',
               ],
            ],
         ],
      ],
   ],

See the section about types for more details.

Type in relation to a foreign table’s field

The type of the record is fetched from the record specified in field `foreign_table`'`

The type of the record is fetched from the record specified in field foreign_table’`

The following table tx_styleguide_type_foreign stores its relation to the table tx_styleguide_type in the field foreign_table.

The type of the table tx_styleguide_type_foreign comes from the content of the field tx_styleguide_type:record_type of the related field.

The type is therefore defined via type = 'foreign_table:record_type'.

The control section of the table tx_styleguide_type_foreign looks like this:

   'ctrl' => [ 
      'title' => 'Form engine - type stored in foreign table',
      'label' => 'title',
      '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' => 'foreign_table:record_type',
   ],

The field foreign_table in the same table is a normal singleSelect field. It can be any kind of 1 - 1 or 1 - n relation.

      'foreign_table' => [ 
         'label' => 'type stored in foreign table',
         'config' => [ 
            'type' => 'select',
            'renderType' => 'selectSingle',
            'foreign_table' => 'tx_styleguide_type',
            'minitems' => 1,
            'maxitems' => 1,
            'size' => 1,
            'default' => 0,
         ],
      ],
      // Example from extension "styleguide", table "tx_styleguide_type_foreign"