How to use enablecolumns in the ctrl section of TCA
All enable column definitions (hidden, starttime, endtime, fe_groups) are
automatically created if they are registered in the ctrl section in the main
TCA (not in the overrides) of a table.
palettes as known from Core TCA definitions have to be defined in the TCA of a custom table however. If the fields should be editable by backend users, the also have to be added to the types definitions.
Examples of column enable configurations
Define all enablecolumn fields
The conference table uses all enable columns:
<?php
return [
'ctrl' => [
'title' => 'my_extension.db:conference',
'label' => 'title',
'descriptionColumn' => 'internal_notes',
'default_sortby' => 'conference_date DESC',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'editlock' => 'editlock',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'translationSource' => 'l10n_source',
'versioningWS' => true,
'origUid' => 't3_origuid',
'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Conference.svg',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
'columns' => [
'title' => [
'label' => 'my_extension.db:conference.title',
'config' => [
'type' => 'input',
'required' => true,
'max' => 255,
'eval' => 'trim',
],
],
'conference_date' => [
'label' => 'my_extension.db:conference.conference_date',
'config' => [
'type' => 'datetime',
'format' => 'date',
'required' => true,
],
],
'internal_notes' => [
'label' => 'my_extension.db:conference.internal_notes',
'config' => [
'type' => 'text',
'rows' => 3,
],
],
],
// The fields of the other tabs are added in Configuration/TCA/Overrides/
'types' => [
'0' => [
'showitem' => '
title, conference_date,
--div--;my_extension.db:tab.program,
--div--;my_extension.db:tab.details,
--div--;core.form.tabs:categories,
--div--;core.form.tabs:access,
hidden, --palette--;;access, fe_group, editlock,
--div--;core.form.tabs:language,
--palette--;;language,
--div--;my_extension.db:tab.comments,
--div--;core.form.tabs:notes,
internal_notes,
',
],
],
'palettes' => [
'access' => [
'label' => 'core.form.palettes:access',
'showitem' => 'starttime, endtime',
],
'language' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
];
The access tab of its form shows the fields, starttime and endtime
in a palette:
<?php
return [
'ctrl' => [
'title' => 'my_extension.db:conference',
'label' => 'title',
'descriptionColumn' => 'internal_notes',
'default_sortby' => 'conference_date DESC',
'tstamp' => 'tstamp',
'crdate' => 'crdate',
'delete' => 'deleted',
'editlock' => 'editlock',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
'fe_group' => 'fe_group',
],
'languageField' => 'sys_language_uid',
'transOrigPointerField' => 'l10n_parent',
'transOrigDiffSourceField' => 'l10n_diffsource',
'translationSource' => 'l10n_source',
'versioningWS' => true,
'origUid' => 't3_origuid',
'iconfile' => 'EXT:my_extension/Resources/Public/Icons/Conference.svg',
'security' => [
'ignorePageTypeRestriction' => true,
],
],
'columns' => [
'title' => [
'label' => 'my_extension.db:conference.title',
'config' => [
'type' => 'input',
'required' => true,
'max' => 255,
'eval' => 'trim',
],
],
'conference_date' => [
'label' => 'my_extension.db:conference.conference_date',
'config' => [
'type' => 'datetime',
'format' => 'date',
'required' => true,
],
],
'internal_notes' => [
'label' => 'my_extension.db:conference.internal_notes',
'config' => [
'type' => 'text',
'rows' => 3,
],
],
],
// The fields of the other tabs are added in Configuration/TCA/Overrides/
'types' => [
'0' => [
'showitem' => '
title, conference_date,
--div--;my_extension.db:tab.program,
--div--;my_extension.db:tab.details,
--div--;core.form.tabs:categories,
--div--;core.form.tabs:access,
hidden, --palette--;;access, fe_group, editlock,
--div--;core.form.tabs:language,
--palette--;;language,
--div--;my_extension.db:tab.comments,
--div--;core.form.tabs:notes,
internal_notes,
',
],
],
'palettes' => [
'access' => [
'label' => 'core.form.palettes:access',
'showitem' => 'starttime, endtime',
],
'language' => [
'showitem' => 'sys_language_uid, l10n_parent',
],
],
];
Common enable fields
Most tables use the fields hidden, starttime and endtime. The backend
shows them in the record information:
The enable columns of a conference in the Access tab
Enablecolumns / enablefields usage
Most ways of retrieving records in the frontend automatically respect the
ctrl->enablecolumns
settings:
Enablecolumns in TypoScript
Records retrieved in TypoScript via the objects RECORDS, CONTENT automatically respect the settings in section ctrl->enablecolumns.
Enablecolumns / enablefields in Extbase
In Extbase repositories the records are hidden in the frontend by default,
however this behaviour can be disabled by setting
$query in the
repository.
Enablecolumns in queries
Using the QueryBuilder enable columns restrictions are automatically applied.
The same is true when select() is called on the connection.
See the restriction builder for details.