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.
Grouping fields (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 Record types definitions.
Examples of column enable configurations
<?php
return [
'ctrl' => [
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
],
// ...
],
'palettes' => [
'paletteHidden' => [
'showitem' => '
hidden
',
],
'paletteAccess' => [
'showitem' => '
starttime, endtime,
--linebreak--,
fe_group',
],
],
'types' => [
0 => [
'showitem' => '
--div--;core.form.tabs:general,
[...],
--div--;core.form.tabs:access,
--palette--;;paletteHidden,
--palette--;;paletteAccess,
',
],
],
];
Define all enablecolumn fields
Make table hideable
Common enable fields
[
'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',
'enablecolumns' => [
'disabled' => 'hidden',
'starttime' => 'starttime',
'endtime' => 'endtime',
],
'security' => [
'ignorePageTypeRestriction' => true,
],
],
]
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.