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.[table name].[field].types.[type] or field level: TCAdefaults.[table name].[field]

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:

  1. Database field default value
  2. Value from $GLOBALS['TCA']
  3. Field-level ref:user TSconfig <userTsTcaDefaults>
  4. Type-level ref:user TSconfig <userTsTcaDefaults>
  5. Field-level TCAdefaults configuration
  6. Type-level TCAdefaults configuration
  7. Value from "defVals" GET variables
  8. Value from previous record based on useColumnsForDefaultValues

However, the order for default values used by the \TYPO3\CMS\Core\DataHandling\DataHandler if a particular field is inaccessible to a user will be:

  1. Value from $GLOBALS['TCA']
  2. 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:

EXT:site_package/Configuration/user.tsconfig
# Show newly created pages by default
TCAdefaults.pages.hidden = 0
Copied!

If 'hidden' is in the list, it gets overridden with the "neighbor" record value (see \TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRowInitializeNew::setDefaultsFromNeighborRow) 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/TCA/Overrides folder of an extension:

EXT:site_package/Configuration/TCA/Overrides/pages.php
$GLOBALS['TCA']['pages']['ctrl']['useColumnsForDefaultValues'] = 'doktype,fe_group';
Copied!

Example: Set type specific default values in user TSconfig

EXT:site_package/Configuration/user.tsconfig
TCAdefaults.tt_content {
    header_layout = 1
    # Use specific default values for certain types
    header_layout.types {
        textmedia = 3
        image = 2
    }
}
Copied!

In this example: if a user with no write access to the field tt_content.header_layout 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.