TCAdefaults
New in version 14.0
The
TCAdefaults
configuration has been extended to support
type-specific syntax enabling different default values based on the record type.
This allows default
values of TCA
fields that are available for various TCA
column types to be set or overridden, for instance for
type=input.
Default values can be set at the type level: TCAdefaults.
or field level: TCAdefaults.
This key is also available at the Page TSconfig level. The order that default values are set when creating new records in the backend is this:
- Database field default value
- Value from
$GLOBALS
['TCA'] - Field-level ref:
user TSconfig <user
Ts Tca Defaults> - Type-level ref:
user TSconfig <user
Ts Tca Defaults> - Field-level
TCAdefaults
configuration - Type-level
TCAdefaults
configuration - Value from "defVals" GET variables
- Value from previous record based on useColumnsForDefaultValues
However, the order for default values used by the
\TYPO3\
if a particular field is inaccessible
to a user will be:
- Value from
$GLOBALS
['TCA'] - Value from User TSconfig (these settings)
So these will be the values that are set if the user has no access to the field anyway.
Example:
# Show newly created pages by default
TCAdefaults.pages.hidden = 0
Attention
This example will not work when creating the page from the context menu
since this is triggered by the values listed in the ctrl
section of
typo3/
:
'ctrl' => [
'useColumnsForDefaultValues' => 'doktype,fe_group,hidden',
...
]
If 'hidden' is in the list, it gets overridden with the "neighbor" record value (see
\TYPO3\
)
and as the value is set - usually to '0' - it will not be overridden
again. To make it work as expected, that value must be overridden. This
can be done for example in the Configuration/
folder
of an extension:
$GLOBALS['TCA']['pages']['ctrl']['useColumnsForDefaultValues'] = 'doktype,fe_group';
Example: Set type specific default values in user TSconfig
TCAdefaults.tt_content {
header_layout = 1
# Use specific default values for certain types
header_layout.types {
textmedia = 3
image = 2
}
}
In this example: if a user with no write access to the field tt_
creates a new content element of type textmedia
the header layout will be set
to 3. If the user does have write access to the field, 3 will be used by default
and they may change it.