Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions Documentation/PageTsconfig/TcaDefaults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,40 @@
TCAdefaults
===========

.. versionadded:: 14.0
The :typoscript:`TCAdefaults` configuration has been extended to support
type-specific syntax similar to `TCEFORM <https://docs.typo3.org/permalink/t3tsref:tceform>`_,
enabling different default values based on the record type.

This allows to set or override the `default` values of `TCA` fields that is available
for various TCA types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.
for various TCA column types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.

The full path of a setting include the table and the field name: `TCAdefaults.[table name].[field]`
Default values can be set on type level: `TCAdefaults.[table name].[field].types.[type]`
or field level: `TCAdefaults.[table name].[field]`.

This key is also available on :ref:`User TSconfig level <userTsTcaDefaults>`, the order of default
This key is also available on :ref:`User TSconfig level <userTsTcaDefaults>` the order of default
values when creating new records in the backend is this:

#. Database field default value
#. Value from `$GLOBALS['TCA']`
#. Value from :ref:`user TSconfig <userTsTcaDefaults>`
#. Value from page TSconfig (these settings)
#. Field-level ref:`user TSconfig <userTsTcaDefaults>`
#. Type-level ref:`user TSconfig <userTsTcaDefaults>`
#. Field-level :typoscript:`TCAdefaults` configuration
#. Type-level :typoscript:`TCAdefaults` configuration
#. Value from "defVals" GET variables
#. Value from previous record based on
:ref:`useColumnsForDefaultValues <t3tca:ctrl-reference-usecolumnsfordefaultvalues>`

`TCAdefaults` set via page TSconfig are ignored if the current user has no
write access to the affected field. In this case use
:ref:`User TSconfig level <userTsTcaDefaults>`.

.. note::
`TCAdefaults` is not applied to :ref:`FlexForm <t3coreapi:flexforms>` values.
These can only be addressed via :xml:`<default>` elements within the
FlexForm data structure.


.. _pageTsTcaDefaults-example:

Example: Do not hide newly created pages by default
Expand All @@ -37,3 +51,27 @@ Example: Do not hide newly created pages by default
:caption: EXT:site_package/Configuration/page.tsconfig

TCAdefaults.pages.hidden = 0

.. _pageTsTcaDefaults-example-type:

Example: Set type specific default values
=========================================

.. code-block:: typoscript
:caption: EXT:site_package/Configuration/page.tsconfig

TCAdefaults.tt_content {
header_layout = 1
header_layout.types {
textmedia = 3
image = 2
}

frame_class = default
frame_class.types {
textmedia = ruler-before
image = none
}

space_before_class = none
}
44 changes: 38 additions & 6 deletions Documentation/UserTsconfig/TcaDefaults.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,29 @@
TCAdefaults
===========

.. versionadded:: 14.0
The :typoscript:`TCAdefaults` configuration has been extended to support
type-specific syntax enabling different default values based on the record type.

This allows to set or override the `default` values of `TCA` fields that is available
for various TCA types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.
for various TCA column types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.

The full path of a setting include the table and the field name: `TCAdefaults.[table name].[field]`
Default values can be set on type level: `TCAdefaults.[table name].[field].types.[type]`
or field level: `TCAdefaults.[table name].[field]`.

This key is also available on :ref:`Page TSconfig level <pageTsTcaDefaults>`, the order of default
values when creating new records in the backend is this:

#. Value from :php:`$GLOBALS['TCA']`
#. Value from User TSconfig (these settings)
#. Value from :ref:`Page TSconfig <pageTsTcaDefaults>`

#. Database field default value
#. Value from `$GLOBALS['TCA']`
#. Field-level ref:`user TSconfig <userTsTcaDefaults>`
#. Type-level ref:`user TSconfig <userTsTcaDefaults>`
#. Field-level :typoscript:`TCAdefaults` configuration
#. Type-level :typoscript:`TCAdefaults` configuration
#. Value from "defVals" GET variables
#. Value from previous record based on 'useColumnsForDefaultValues'
#. Value from previous record based on
:ref:`useColumnsForDefaultValues <t3tca:ctrl-reference-usecolumnsfordefaultvalues>`

However the order for default values used by :php:`\TYPO3\CMS\Core\DataHandling\DataHandler` if a certain
field is not granted access to for user will be:
Expand Down Expand Up @@ -62,3 +72,25 @@ of an extension:
:caption: EXT:site_package/Configuration/TCA/Overrides/pages.php

$GLOBALS['TCA']['pages']['ctrl']['useColumnsForDefaultValues'] = 'doktype,fe_group';

.. _userTsTcaDefaults-example-types:

Example: Set type specific default values in user TSconfig
==========================================================

.. code-block:: typoscript
:caption: 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
}
}

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 as default
and they may change it.