Examples demonstrating the ctrl section of TCA
A common table has a configuration such as this:
[
'ctrl' => [
'title' => 'Form engine - Common table control',
'label' => 'title',
'descriptionColumn' => 'description',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'sortby' => 'sorting',
'default_sortby' => 'title',
'versioningWS' => true,
'rootLevel' => -1,
'iconfile' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'translationSource' => 'l10n_source',
'searchFields' => 'title,description',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
],
'security' => [
'ignorePageTypeRestriction' => true,
],
],
]
Minimal table configuration
[
'ctrl' => [
'title' => 'LLL:EXT:styleguide/Resources/Private/Language/locallang.xlf:minimalTableTitle',
'label' => 'title',
'iconfile' => 'EXT:styleguide/Resources/Public/Icons/tx_styleguide.svg',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
'columns' => [
'title' => [
'label' => 'LLL:EXT:styleguide/Resources/Private/Language/locallang.xlf:minimalTableTitleField',
'config' => [
'type' => 'input',
],
],
],
'types' => [
[
'showitem' => 'title',
],
],
]
Property label
is a mandatory setting, but the above properties are a recommended
minimum. The list module shows an icon and a translated title of the table, and it uses the value of
field title
as title for single rows. Single record administration however is limited with this setup: This
table does not implement soft delete, record rows can not be sorted between each other, record localization is not
possible, and much more. In the database, only columns uid
, pid
and title
are needed
in ext_
with this setup.
Core table tt_content
Table tt_
makes much more excessive use of the ['ctrl']
section:
[
'ctrl' => [
'label' => 'header',
'label_alt' => 'subheader,bodytext',
'descriptionColumn' => 'rowDescription',
'sortby' => 'sorting',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'editlock' => 'editlock',
'title' => 'LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:tt_content',
'delete' => 'deleted',
'versioningWS' => true,
'groupName' => 'content',
'type' => 'CType',
'hideAtCopy' => true,
'prependAtCopy' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.prependAtCopy',
'copyAfterDuplFields' => 'colPos,sys_language_uid',
'useColumnsForDefaultValues' => 'colPos,sys_language_uid,CType',
'transOrigPointerField' => 'l18n_parent',
'transOrigDiffSourceField' => 'l18n_diffsource',
'languageField' => 'sys_language_uid',
'translationSource' => 'l10n_source',
'previewRenderer' => 'TYPO3\\CMS\\Backend\\Preview\\StandardContentPreviewRenderer',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'typeicon_column' => 'CType',
'typeicon_classes' => [
'header' => 'mimetypes-x-content-header',
'text' => 'mimetypes-x-content-text',
'textpic' => 'mimetypes-x-content-text-picture',
'image' => 'mimetypes-x-content-image',
'textmedia' => 'mimetypes-x-content-text-media',
'bullets' => 'mimetypes-x-content-list-bullets',
'table' => 'mimetypes-x-content-table',
'uploads' => 'mimetypes-x-content-list-files',
'list' => 'mimetypes-x-content-plugin',
'shortcut' => 'mimetypes-x-content-link',
'script' => 'mimetypes-x-content-script',
'div' => 'mimetypes-x-content-divider',
'html' => 'mimetypes-x-content-html',
'default' => 'mimetypes-x-content-text',
'menu_abstract' => 'content-menu-abstract',
'menu_categorized_content' => 'content-menu-categorized',
'menu_categorized_pages' => 'content-menu-categorized',
'menu_pages' => 'content-menu-pages',
'menu_subpages' => 'content-menu-pages',
'menu_recently_updated' => 'content-menu-recently-updated',
'menu_related_pages' => 'content-menu-related',
'menu_sitemap' => 'content-menu-sitemap',
'menu_sitemap_pages' => 'content-menu-sitemap-pages',
'menu_section' => 'content-menu-section',
'menu_section_pages' => 'content-menu-section',
],
'searchFields' => 'header,header_link,subheader,bodytext,pi_flexform',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
]
A few remarks:
- When tt_content records are displayed in the backend, the "label" property indicates that you will see the content from the field named "header" shown as the title of the record. If that field is empty, the content of field subheader and if empty, of field bodytext is used as title.
- The field called "sorting" will be used to determine the order in which tt_content records are displayed within each branch of the page tree.
- The title for the table as shown in the backend is defined as coming from a "locallang" file.
- The "type" field will be the one named "CType". The value of this field determines the set of fields shown in the edit forms in the backend, see the ['types'] section for details.
- Of particular note is the "enablecolumns" property. It is quite extensive for this table since it is a frontend-related table. Thus proper access rights, publications dates, etc. must be enforced.
- Every type of content element has its own icon and its own class, used in conjunction with the Icon API to visually represent that type in the TYPO3 backend.
Extended container examples
Disable a built-in wizard
<?php
return [
'ctrl' => [
// ...
'container' => [
'inlineControlContainer' => [
'fieldWizard' => [
'localizationStateSelector' => [
'disabled' => true,
],
],
],
],
],
// ...
];
This disables the default localization
fieldWizard of
inline
.
Add your own wizard
Register an own node in a ext_
:
<?php
declare(strict_types=1);
use MyVendor\MyExtension\FormEngine\FieldWizard\ReferencesToThisRecordWizard;
defined('TYPO3') or die();
$GLOBALS['TYPO3_CONF_VARS']['SYS']['formEngine']['nodeRegistry'][1486488059] = [
'nodeName' => 'ReferencesToThisRecordWizard',
'priority' => 40,
'class' => ReferencesToThisRecordWizard::class,
];
Register the new node as field
of tt_
table in an
Configuration/
file:
<?php
declare(strict_types=1);
defined('TYPO3') or die();
$GLOBALS['TCA']['tt_content']['ctrl']['container'] = [
'outerWrapContainer' => [
'fieldWizard' => [
'ReferencesToThisRecordWizard' => [
'renderType' => 'ReferencesToThisRecordWizard',
],
],
],
];
In PHP, the node has to implement an interface, but can return any additional HTML which is rendered in the "OuterWrapContainer" between the record title and the field body when editing a record:
Add fieldInformation to field of type inline
This example can be found in Add a custom fieldInformation.