Record types
See also
Field types (config > type) are a different concept to record types.
A types section is mandatory in all table definitions.
The types section is an array of types $GLOBALS each
containing a showitem key which determines which fields will be displayed in
the backend form for the record. Most TCA tables will only contain one type.
However, it is possible to have many types in the same table with different fields being displayed depending on the type. Then a new database field needs to be created to save the type with the data. This field is set in $GLOBALS['TCA'][$table]['ctrl']['type'].
Defining multiple types in one table is similar to Single Table Inheritance in Object-orientated programming.
Table of Contents
Subpages
Changed in version 13.3
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. See also the automatically added system fields.
A basic table without distinct types
A table record supporting only one type defines which fields should be displayed in the backend form for the default type.
As an example, a comment on a blog post can be stored in a table as follows:
<?php
return [
'ctrl' => [
'title' => 'Comment',
'label' => 'name',
'enablecolumns' => [
'disabled' => 'hidden',
],
],
'types' => [
'0' => [
'showitem' => 'hidden, name, email, content, date',
],
],
'columns' => [
'name' => [
'label' => 'Name',
'config' => [
'type' => 'input',
],
],
'email' => [
'label' => 'Email',
'config' => [
'type' => 'email',
],
],
'content' => [
'label' => 'Comment',
'config' => [
'type' => 'text',
],
],
'date' => [
'label' => 'Date',
'config' => [
'type' => 'datetime',
],
],
],
];
The types section is mandatory.
Supporting multiple record types in the same table
If a table supports multiple record types, the type of the record must be
saved in a dedicated database field, commonly named record_ or just type.
Usually a select field is used for that purpose.
The name of this field is registered in the ctrl section via property
type.
As an example, a blog post might have several types where the fields displayed in the backend differ:
<?php
return [
'ctrl' => [
'title' => 'LLL:my_extension.db:tx_myextension_domain_model_post',
'label' => 'title',
'type' => 'record_type',
'typeicon_classes' => [
'0' => 'tx-blog-post',
'link' => 'tx-blog-post-link',
'special' => 'tx-blog-post-special',
],
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
],
'types' => [
'0' => [
'showitem' => '
record_type, blog, title, date, author, content,
--div--;core.form.tabs:access,
hidden,
--palette--;;paletteStartStop,
fe_group,
--div--;core.form.tabs:language,
--palette--;;paletteLanguage,
',
],
'link' => [
'title' => 'LLL:my_extension.db:link.title',
'showitem' => 'record_type, blog, title, date, author, link',
'creationOptions' => [
'defaultValues' => [
'author' => 'External Author',
],
],
],
'special' => [
'title' => 'LLL:my_extension.db:special.title',
'showitem' => 'record_type, blog, title, date, author, content, tags',
'columnsOverrides' => [
'author' => [
'config' => [
'required' => true,
],
],
'content' => [
'description' => 'You can use Markdown syntax for the content.',
'config' => [
'renderType' => 'codeEditor',
],
],
],
],
],
'palettes' => [
'paletteStartStop' => [
'showitem' => 'starttime, endtime',
],
'paletteLanguage' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
'columns' => [
'record_type' => [
'label' => 'LLL:my_extension.labels:post_types',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['label' => 'Blog Post', 'value' => '0'],
['label' => 'Link to External Blog Post', 'value' => 'link'],
['label' => 'Special Blog Post', 'value' => 'special'],
],
'default' => '0',
],
],
'blog' => [
'label' => 'Blog',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_myextension_domain_model_blog',
],
],
'title' => [
'label' => 'Title',
'config' => [
'type' => 'input',
],
],
'date' => [
'label' => 'Date',
'config' => [
'type' => 'datetime',
],
],
'author' => [
'label' => 'Author',
'config' => [
'type' => 'input',
],
],
'content' => [
'label' => 'Content',
'config' => [
'type' => 'text',
],
],
'link' => [
'label' => 'Link',
'config' => [
'type' => 'link',
],
],
'tags' => [
'label' => 'Tags',
'config' => [
'type' => 'input',
],
],
],
];
For each record type you can define additional creationOptions and change field display definitions via columnsOverrides.
It is also possible to define previewRenderers.
You can also define icons for each type using the property ctrl -> typeicon_classes.
Properties of types section of TCA
| Name | Type | Scope |
|---|---|---|
array of table names or ['*']
|
||
| array (columns fields overrides) | Display | |
| list of options | ||
| array | ||
| bool | ||
| bool | ||
| string | language reference | ||
| boolean | ||
| string, name of a field | Display | |
| string, comma separated list of fields | Display | |
| bool | Display | |
| string | Display | |
| string (list of field configuration sets) | ||
| plain text label or label reference | Display | |
| array | Display |
-
- Type
- array of table names or
['*'] - Default
['pages', 'sys_category', 'sys_ file_ reference', 'sys_ file_ collection'] - TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['allowedRecordTypes']
New in version 14.2 Deprecation: #108557 - TCA option allowedRecordTypes for Page Types
This property replaces the now deprecated method
Page.Doktype Registry->add Allowed Record Types () Note
This property is only interpreted in the table
pages.The array can contain a list of table names or a single entry with an asterisk
*to allow all types within a page type.See TYPO3 Explained: Create new Page Type for a complete example.
-
- Type
- array (columns fields overrides)
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['columnsOverrides']
- Scope
- Display
- Examples
- Examples for columnsOverrides
Changed or added ['columns'] field display definitions.
This allows different field column definitions to be applied when a record of this type is edited. Currently, only the display of form fields is affected, not data handling.
A typical property that can be changed is
render.Type The core uses this property to override the "bodytext" field config of table "tt_content". If a record of type "text" is edited, it adds "enableRichtext = 1" to trigger an RTE to the default "bodytext" configuration, and if a type "table" is edited, it adds "renderType = textTable" and "wrap = off" to "bodytext".
The FormEngine basically merges "columnsOverrides" over the default "columns" field after the record type has been determined.
Attention
It is not possible to override any properties in "Proc." scope: The DataHandler does not take "columnsOverrides" into account. Only pure "Display" related properties can be overridden. This especially means that columns config 'type' must not be set to a different value.
-
- Type
- list of options
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['creationOptions']
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['creationOptions']['defaultValues']
- Examples
- the example that creates the blog plugin at once
Default values inserted into the fields of the
tt_record on creation via the "New Content Element" wizardcontent Can be overridden with page TSconfig option tt_content_defValues.
-
- Type
- bool
- Default
- true
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['creationOptions']['enableDirectRecordTypeCreation']
New in version 14.0
Record types registered via TCA are automatically displayed in the "Create new record" component in the backend module Content > Records.
A record type can be removed from that component via:
EXT:my_extension/Configuration/TCA/Overrides/tx_myextension_mytable.php$GLOBALS['TCA']['tx_myextension_mytable']['types']['my_type']['creationOptions']['enableDirectRecordTypeCreation'] = false;Copied!Event
\TYPO3\can be used for more sophisticated modification of the dialogue.CMS\ Backend\ Controller\ Event\ Modify New Record Creation Links Event
-
- Type
- bool
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['creationOptions']['saveAndClose']
- Examples
- the example that creates the blog plugin at once
If true, clicking on the new element wizard will take the user directly to the Content > Layout module, rather than showing the edit form from the form engine.
Can be overridden with page TSconfig option saveAndClose.
-
- Type
- string | language reference
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['creationOptions']['title']
New in version 14.0
With this option it is possible to set an individual title for the record type, to be used as label on the creation link in the "Create new record" component.
EXT:my_extension/Configuration/TCA/Overrides/tx_myextension_mytable.php$GLOBALS['TCA']['tx_myextension_mytable']['types']['my_type']['creationOptions']['title'] = 'my_extension.db.myType:title';Copied!
-
- Type
- boolean
- Default
- true
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['isViewable']
New in version 14.2 Feature: #97898 - TCA option isViewable for page types
Note
This property is only interpreted in the table
pages.Defines whether a page of this page type can be viewed in the frontend. A page type that is not viewable:
- cannot be linked, neither in the link browser nor by a TypoLink in the frontend,
- answers a direct call in the frontend with a 404 error,
- has no preview button in the backend.
TYPO3 sets this to
falsefor the page types spacer (199) and folder (254). All other page types are viewable as long as the option is not set.EXT:my_extension/Configuration/TCA/Overrides/pages.php$GLOBALS['TCA']['pages']['types']['116']['isViewable'] = false;Copied!In the backend, the page TSconfig setting TCEMAIN.preview.disableButtonForDokType decides instead: as soon as it is set for a page, the preview button and the link browser follow that list of page types and
isis not considered for them. The frontend always followsViewable is.Viewable
-
- Type
- string, name of a field
- TCA path
- $GLOBALS['TCA'][$table]['types'][$recordType]['label']
- Scope
- Display
New in version 14.2 Feature: #108581 - Record type specific label configuration
Defines the primary field used as a type-specific label for a record type, overriding the label defined in $GLOBALS['TCA'][$table]['ctrl']['label'].
All places in TYPO3 that use
Backendautomatically benefit from this feature without any code changes. This includes record lists, page trees, history views, workspaces, and similar backend modules.Utility:: get Record Title () This is especially useful for tables like
tt_where different content element types may benefit from showing different fields. For example, an "Image" content element could display the image caption, while a "Text" element shows the header field.content EXT:my_extension/Configuration/TCA/tx_myextension_mytable.php<?php return [ 'ctrl' => [ 'title' => 'My table', 'label' => 'header', 'type' => 'record_type', ], 'types' => [ 'article' => [ 'showitem' => 'record_type, header, teaser', 'label_alt' => 'teaser', ], 'event' => [ 'showitem' => 'record_type, header, event_date, location', 'label_alt' => 'event_date,location', 'label_alt_force' => true, ], ], 'columns' => [ 'record_type' => [ 'label' => 'Type', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'items' => [ ['label' => 'Article', 'value' => 'article'], ['label' => 'Event', 'value' => 'event'], ], ], ], 'header' => [ 'label' => 'Header', 'config' => [ 'type' => 'input', ], ], 'teaser' => [ 'label' => 'Teaser', 'config' => [ 'type' => 'text', ], ], 'event_date' => [ 'label' => 'Event date', 'config' => [ 'type' => 'datetime', ], ], 'location' => [ 'label' => 'Location', 'config' => [ 'type' => 'input', ], ], ], ];In this example:
- All types use
headeras the primary label field (fromctrl).['label'] - The article type displays the
teaserfield ifheaderis empty. - The event type displays
headertogether withevent_anddate location(sincelabel_is enabled).alt_ force
-
- Type
- string, comma separated list of fields
- TCA path
- $GLOBALS['TCA'][$table]['types'][$recordType]['label_alt']
- Scope
- Display
New in version 14.2 Feature: #108581 - Record type specific label configuration
Alternative field(s) used when label is empty (or as additional fields)
-
- Type
- bool
- Default
- false
- TCA path
- $GLOBALS['TCA'][$table]['types'][$recordType]['label_alt_force']
- Scope
- Display
New in version 14.2 Feature: #108581 - Record type specific label configuration
Force display of alternative fields alongside the primary label
-
- Type
- string
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['previewRenderer']
- Scope
- Display
- Examples
- PreviewRenderer examples
To configure a preview renderer for the whole table see previewRenderer.
Configures a backend preview for a content element.
Have also a look at configure a custom backend preview for more details.
Use property previewRenderer of section ctrl to configure the preview globally for the whole table.
-
- Type
- string (list of field configuration sets)
- Required
true
- TCA path
- $GLOBALS['TCA'][$table]['types'][$type]['showitem']
- Examples
- Display all fields on one page of the form
Configuration of the displayed order of fields in FormEngine and their tab alignment.
The whole string is a comma
,separated list of tokens. Each token can have keywords separated by semicolon;.Each comma separated token is one of the following:
fieldName;field Label - Name of a field to show. Optionally an alternative label (plain text label or label reference) to override the default label from columns section.
--palette--;palette Label;palette Name -
Name of a palette to show. The label (plain text label or label reference) is optional. If set, it is shown above the single palette fields. The palette name is required and must reference a palette from the palette section.
--palette--;;caching // Show palette "caching" without additional label --palette--;Caching;caching // Show palette "caching" with label "Caching"Copied! --div--;tab Label - Put all fields after this token onto a new tab and name the tab as given in "tabLabel" (plain text label or label reference).
Note
It is good practice to add a comma in excess behind the very last field name as shown in the examples above. The FormEngine code will ignore this, but it helps developers to not forget about a comma when additional fields are added, which can suppress an annoying "Why is my new field not displayed?" bug hunt.
Extensions can also modify
showitemvalues by utilizingExtension. See customization examples for details.Management Utility:: add To All TCAtypes ()
-
- Type
- plain text label or label reference
- TCA path
- $GLOBALS['TCA'][$table]['types'][$recordType]['title']
- Scope
- Display
New in version 14.0 Feature: #108027 - Type-specific title in TCA types section
It is now possible to define a type-specific
titlein the TCAtypessection.The
titlein the TCAtypessection defines a type specific title that is displayed in the backend when creating or editing a record of that type.The value is also available in the Schema API (
\TYPO3\), making type-specific titles available when usingCMS\ Core\ Schema\ Tca Schema Factory $schema->getand in the FormEngine (Title () Tcadata provider).Types Ctrl Overrides EXT:my_extension/Configuration/TCA/tx_myextension_domain_model_post.php<?php return [ 'ctrl' => [ 'title' => 'LLL:my_extension.db:tx_myextension_domain_model_post', 'label' => 'title', 'type' => 'record_type', 'typeicon_classes' => [ '0' => 'tx-blog-post', 'link' => 'tx-blog-post-link', 'special' => 'tx-blog-post-special', ], 'enablecolumns' => [ 'disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime', 'fe_group' => 'fe_group', ], 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', ], 'types' => [ '0' => [ 'showitem' => ' record_type, blog, title, date, author, content, --div--;core.form.tabs:access, hidden, --palette--;;paletteStartStop, fe_group, --div--;core.form.tabs:language, --palette--;;paletteLanguage, ', ], 'link' => [ 'title' => 'LLL:my_extension.db:link.title', 'showitem' => 'record_type, blog, title, date, author, link', 'creationOptions' => [ 'defaultValues' => [ 'author' => 'External Author', ], ], ], 'special' => [ 'title' => 'LLL:my_extension.db:special.title', 'showitem' => 'record_type, blog, title, date, author, content, tags', 'columnsOverrides' => [ 'author' => [ 'config' => [ 'required' => true, ], ], 'content' => [ 'description' => 'You can use Markdown syntax for the content.', 'config' => [ 'renderType' => 'codeEditor', ], ], ], ], ], 'palettes' => [ 'paletteStartStop' => [ 'showitem' => 'starttime, endtime', ], 'paletteLanguage' => [ 'showitem' => 'sys_language_uid, l10n_parent', ], ], 'columns' => [ 'record_type' => [ 'label' => 'LLL:my_extension.labels:post_types', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'items' => [ ['label' => 'Blog Post', 'value' => '0'], ['label' => 'Link to External Blog Post', 'value' => 'link'], ['label' => 'Special Blog Post', 'value' => 'special'], ], 'default' => '0', ], ], 'blog' => [ 'label' => 'Blog', 'config' => [ 'type' => 'select', 'renderType' => 'selectSingle', 'foreign_table' => 'tx_myextension_domain_model_blog', ], ], 'title' => [ 'label' => 'Title', 'config' => [ 'type' => 'input', ], ], 'date' => [ 'label' => 'Date', 'config' => [ 'type' => 'datetime', ], ], 'author' => [ 'label' => 'Author', 'config' => [ 'type' => 'input', ], ], 'content' => [ 'label' => 'Content', 'config' => [ 'type' => 'text', ], ], 'link' => [ 'label' => 'Link', 'config' => [ 'type' => 'link', ], ], 'tags' => [ 'label' => 'Tags', 'config' => [ 'type' => 'input', ], ], ], ];It is possible to insert plain text values here, however it is recommended to keep all labels in a translation file and reference the label with the special syntax shown above.
-
- Type
- array
- TCA path
- $GLOBALS['TCA'][$table]['types'][$recordType]['wizardSteps']
- Scope
- Display
New in version 14.2 Feature: #109271 - Add TCA configuration for page creation wizard steps
It is possible to configure fields, steps (and their order) in the page creation wizard using TCA.
Defines the steps shown in the page creation wizard for the
pagestable.Each step is identified by a unique key and contains a localized title and a list of fields to display in that step. The configured steps are sorted and may be positioned relative to other steps by using the
beforeorafteroptions.The configuration can be defined per page type, allowing different wizard steps and field assignments depending on the selected page type.
Required fields that are not assigned to any configured wizard step are added automatically to a fallback step, which is appended at the end of the wizard.
EXT:my_extension/Configuration/TCA/Overrides/pages.php<?php defined('TYPO3') or die(); $GLOBALS['TCA']['pages']['types']['123']['wizardSteps'] = [ 'setup' => [ 'title' => 'backend.wizards.page:step.setup', 'fields' => ['title', 'slug', 'nav_title', 'hidden', 'nav_hide'], ], 'special' => [ 'title' => 'backend.wizards.page:wizard.special_step', 'fields' => ['my_custom_field'], 'after' => ['setup'], ], ];For a complete example see TYPO3 Explained, Create new page type.
Changed in version 13.0
The properties bitmask_ and bitmask_
have been removed, it is not considered anymore when rendering
records in the backend record editing interface.
Extensions still using this setting should switch to casual
$GLOBALS fields instead, which
can be powered by columns based on string values.
Extended examples for using the types section of TCA
Display all fields on one page of the form
The table containing the blog comments does not contain many fields. So they can all be displayed on one page of the backend form without using tabs:
<?php
return [
'ctrl' => [
'title' => 'Comment',
'label' => 'name',
'enablecolumns' => [
'disabled' => 'hidden',
],
],
'types' => [
'0' => [
'showitem' => 'hidden, name, email, content, date',
],
],
'columns' => [
'name' => [
'label' => 'Name',
'config' => [
'type' => 'input',
],
],
'email' => [
'label' => 'Email',
'config' => [
'type' => 'email',
],
],
'content' => [
'label' => 'Comment',
'config' => [
'type' => 'text',
],
],
'date' => [
'label' => 'Date',
'config' => [
'type' => 'datetime',
],
],
],
];
Group fields using tabs and use palettes
If a table has a larger number of fields, grouping them into tabs and palettes can improves the backend user experience. Palettes have the additional value that they can be reused across different record types.
<?php
return [
'ctrl' => [
'title' => 'LLL:my_extension.db:tx_myextension_domain_model_post',
'label' => 'title',
'type' => 'record_type',
'typeicon_classes' => [
'0' => 'tx-blog-post',
'link' => 'tx-blog-post-link',
'special' => 'tx-blog-post-special',
],
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
],
'types' => [
'0' => [
'showitem' => '
record_type, blog, title, date, author, content,
--div--;core.form.tabs:access,
hidden,
--palette--;;paletteStartStop,
fe_group,
--div--;core.form.tabs:language,
--palette--;;paletteLanguage,
',
],
'link' => [
'title' => 'LLL:my_extension.db:link.title',
'showitem' => 'record_type, blog, title, date, author, link',
'creationOptions' => [
'defaultValues' => [
'author' => 'External Author',
],
],
],
'special' => [
'title' => 'LLL:my_extension.db:special.title',
'showitem' => 'record_type, blog, title, date, author, content, tags',
'columnsOverrides' => [
'author' => [
'config' => [
'required' => true,
],
],
'content' => [
'description' => 'You can use Markdown syntax for the content.',
'config' => [
'renderType' => 'codeEditor',
],
],
],
],
],
'palettes' => [
'paletteStartStop' => [
'showitem' => 'starttime, endtime',
],
'paletteLanguage' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
'columns' => [
'record_type' => [
'label' => 'LLL:my_extension.labels:post_types',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['label' => 'Blog Post', 'value' => '0'],
['label' => 'Link to External Blog Post', 'value' => 'link'],
['label' => 'Special Blog Post', 'value' => 'special'],
],
'default' => '0',
],
],
'blog' => [
'label' => 'Blog',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_myextension_domain_model_blog',
],
],
'title' => [
'label' => 'Title',
'config' => [
'type' => 'input',
],
],
'date' => [
'label' => 'Date',
'config' => [
'type' => 'datetime',
],
],
'author' => [
'label' => 'Author',
'config' => [
'type' => 'input',
],
],
'content' => [
'label' => 'Content',
'config' => [
'type' => 'text',
],
],
'link' => [
'label' => 'Link',
'config' => [
'type' => 'link',
],
],
'tags' => [
'label' => 'Tags',
'config' => [
'type' => 'input',
],
],
],
];
The syntax for tabs is:
--
Where label can be plain text label or label reference (preferred).
The syntax to insert a palette is:
--
The label can be omitted.
See also
Examples for columnsOverrides in type section of TCA
Demonstrates property: columnsOverrides.
For example the special blog post type might require the author to be set and use a different render type and description for the content:
<?php
return [
'ctrl' => [
'title' => 'LLL:my_extension.db:tx_myextension_domain_model_post',
'label' => 'title',
'type' => 'record_type',
'typeicon_classes' => [
'0' => 'tx-blog-post',
'link' => 'tx-blog-post-link',
'special' => 'tx-blog-post-special',
],
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
],
'types' => [
'0' => [
'showitem' => '
record_type, blog, title, date, author, content,
--div--;core.form.tabs:access,
hidden,
--palette--;;paletteStartStop,
fe_group,
--div--;core.form.tabs:language,
--palette--;;paletteLanguage,
',
],
'link' => [
'title' => 'LLL:my_extension.db:link.title',
'showitem' => 'record_type, blog, title, date, author, link',
'creationOptions' => [
'defaultValues' => [
'author' => 'External Author',
],
],
],
'special' => [
'title' => 'LLL:my_extension.db:special.title',
'showitem' => 'record_type, blog, title, date, author, content, tags',
'columnsOverrides' => [
'author' => [
'config' => [
'required' => true,
],
],
'content' => [
'description' => 'You can use Markdown syntax for the content.',
'config' => [
'renderType' => 'codeEditor',
],
],
],
],
],
'palettes' => [
'paletteStartStop' => [
'showitem' => 'starttime, endtime',
],
'paletteLanguage' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
'columns' => [
'record_type' => [
'label' => 'LLL:my_extension.labels:post_types',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['label' => 'Blog Post', 'value' => '0'],
['label' => 'Link to External Blog Post', 'value' => 'link'],
['label' => 'Special Blog Post', 'value' => 'special'],
],
'default' => '0',
],
],
'blog' => [
'label' => 'Blog',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_myextension_domain_model_blog',
],
],
'title' => [
'label' => 'Title',
'config' => [
'type' => 'input',
],
],
'date' => [
'label' => 'Date',
'config' => [
'type' => 'datetime',
],
],
'author' => [
'label' => 'Author',
'config' => [
'type' => 'input',
],
],
'content' => [
'label' => 'Content',
'config' => [
'type' => 'text',
],
],
'link' => [
'label' => 'Link',
'config' => [
'type' => 'link',
],
],
'tags' => [
'label' => 'Tags',
'config' => [
'type' => 'input',
],
],
],
];
While the field type type cannot be changed in the columns the
render type render can be changed.
Override default values by type
A blog post of type link should have a different default value for the author field then other blog post types:
<?php
return [
'ctrl' => [
'title' => 'LLL:my_extension.db:tx_myextension_domain_model_post',
'label' => 'title',
'type' => 'record_type',
'typeicon_classes' => [
'0' => 'tx-blog-post',
'link' => 'tx-blog-post-link',
'special' => 'tx-blog-post-special',
],
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
],
'types' => [
'0' => [
'showitem' => '
record_type, blog, title, date, author, content,
--div--;core.form.tabs:access,
hidden,
--palette--;;paletteStartStop,
fe_group,
--div--;core.form.tabs:language,
--palette--;;paletteLanguage,
',
],
'link' => [
'title' => 'LLL:my_extension.db:link.title',
'showitem' => 'record_type, blog, title, date, author, link',
'creationOptions' => [
'defaultValues' => [
'author' => 'External Author',
],
],
],
'special' => [
'title' => 'LLL:my_extension.db:special.title',
'showitem' => 'record_type, blog, title, date, author, content, tags',
'columnsOverrides' => [
'author' => [
'config' => [
'required' => true,
],
],
'content' => [
'description' => 'You can use Markdown syntax for the content.',
'config' => [
'renderType' => 'codeEditor',
],
],
],
],
],
'palettes' => [
'paletteStartStop' => [
'showitem' => 'starttime, endtime',
],
'paletteLanguage' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
'columns' => [
'record_type' => [
'label' => 'LLL:my_extension.labels:post_types',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'items' => [
['label' => 'Blog Post', 'value' => '0'],
['label' => 'Link to External Blog Post', 'value' => 'link'],
['label' => 'Special Blog Post', 'value' => 'special'],
],
'default' => '0',
],
],
'blog' => [
'label' => 'Blog',
'config' => [
'type' => 'select',
'renderType' => 'selectSingle',
'foreign_table' => 'tx_myextension_domain_model_blog',
],
],
'title' => [
'label' => 'Title',
'config' => [
'type' => 'input',
],
],
'date' => [
'label' => 'Date',
'config' => [
'type' => 'datetime',
],
],
'author' => [
'label' => 'Author',
'config' => [
'type' => 'input',
],
],
'content' => [
'label' => 'Content',
'config' => [
'type' => 'text',
],
],
'link' => [
'label' => 'Link',
'config' => [
'type' => 'link',
],
],
'tags' => [
'label' => 'Tags',
'config' => [
'type' => 'input',
],
],
],
];
PreviewRenderer examples
Demonstrates property: previewRenderer.
This specifies the preview renderer only for records with the record type myextension_
as determined by the field CType of the table tt_.
This could be used to preview the blog plugin in the Content > Layout module.
$GLOBALS['TCA']['tt_content']['types']['myextension_bloglist']['previewRenderer']
= \MyVendor\MyExtension\Preview\PreviewRenderer::class;
Example: Create the blog plugin at once
Demonstrates property: saveAndClose.
When editors create a new blog plugin in the plugin is automatically saved and the user returned to the Content > Layout module:
<?php
defined('TYPO3') or die();
$GLOBALS['TCA']['tt_content']['types']['myextension_bloglist']
['creationOptions']['saveAndClose'] = true;
Note
This property only takes effect in the table tt_.