Feature: #107281 - Type-specific TCAdefaults support
See forge#107281
Description
The
TCAdefaults configuration has been extended to support
type-specific syntax similar to
TCEFORM, enabling different
default values based on the record type.
This allows configuration like:
# Field-level default (applies to all content types)
TCAdefaults.tt_content.header_layout = 1
# Type-specific defaults (applies only to specific content types)
TCAdefaults.tt_content.header_layout.types.textmedia = 3
TCAdefaults.tt_content.frame_class.types.textmedia = ruler-before
The same syntax is supported in User TSconfig as well.
Type-specific defaults take precedence over field-level defaults, and Page TSconfig overrides User TSconfig following the established inheritance pattern.
Implementation details
The feature is implemented in two main areas:
- Backend forms: The
Databaseclass now processes type-specific defaults when creating new records in the backend.Row Initialize New - DataHandler: The
Dataclass supports type-specific defaults when creating records programmatically via the PHP API.Handler
Important
Type-specific defaults only work when the record type is defined in the new
record values. This happens automatically when using the New Content Element
Wizard (via
def) or when explicitly providing the type field in
the DataHandler datamap (for example,
'CType' => 'textmedia' for
content elements).
If no type information is available during record creation, only
field-level
TCAdefaults will be applied.
Fallback behavior
If no type-specific default is found for a given record type, the system falls back to:
- Field-level
TCAdefaultsconfiguration - TCA
'default'configuration - Database field default value
Automatic field discovery
This enhancement makes
TCAdefaults consistent with
TCEFORM patterns and enables automatic field discovery.
Examples
TCAdefaults.tt_content.header_layout = 1
TCAdefaults.tt_content.header_layout.types.textmedia = 3
TCAdefaults.tt_content.header_layout.types.image = 2
TCAdefaults.tt_content {
header_layout = 1
header_layout.types.textmedia = 3
header_layout.types.image = 2
frame_class = default
frame_class.types.textmedia = ruler-before
frame_class.types.image = none
space_before_class = none
}
use TYPO3\CMS\Core\DataHandling\DataHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility;
$dataHandler = GeneralUtility::makeInstance(DataHandler::class);
$datamap = [
'tt_content' => [
'NEW123' => [
'pid' => 42,
'CType' => 'textmedia',
'header' => 'My Content Element',
// header_layout and frame_class will be set automatically
// based on type-specific TCAdefaults configuration
],
],
];
$dataHandler->start($datamap, [], $backendUser);
$dataHandler->process_datamap();
Impact
This feature provides a more flexible and consistent way to configure default values for different record types, reducing repetitive configuration and improving the user experience when creating new records.
The type-specific syntax aligns
TCAdefaults with the established
TCEFORM pattern, making the configuration more intuitive for
TYPO3 developers and integrators.