Skip to content

Commit 3d3e569

Browse files
committed
[FEATURE] Add type-specific TCAdefaults support
Resolves: TYPO3-Documentation/Changelog-To-Doc#1302 Releases: main
1 parent fd1fbb6 commit 3d3e569

File tree

2 files changed

+81
-11
lines changed

2 files changed

+81
-11
lines changed

Documentation/PageTsconfig/TcaDefaults.rst

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,40 @@
88
TCAdefaults
99
===========
1010

11+
.. versionadded:: 14.0
12+
The :typoscript:`TCAdefaults` configuration has been extended to support
13+
type-specific syntax similar to `TCEFORM <https://docs.typo3.org/permalink/t3tsref:tceform>`_,
14+
enabling different default values based on the record type.
15+
1116
This allows to set or override the `default` values of `TCA` fields that is available
12-
for various TCA types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.
17+
for various TCA column types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.
1318

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

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

25+
#. Database field default value
1926
#. Value from `$GLOBALS['TCA']`
20-
#. Value from :ref:`user TSconfig <userTsTcaDefaults>`
21-
#. Value from page TSconfig (these settings)
27+
#. Field-level ref:`user TSconfig <userTsTcaDefaults>`
28+
#. Type-level ref:`user TSconfig <userTsTcaDefaults>`
29+
#. Field-level :typoscript:`TCAdefaults` configuration
30+
#. Type-level :typoscript:`TCAdefaults` configuration
2231
#. Value from "defVals" GET variables
2332
#. Value from previous record based on
2433
:ref:`useColumnsForDefaultValues <t3tca:ctrl-reference-usecolumnsfordefaultvalues>`
2534

35+
`TCAdefaults` set via page TSconfig are ignored if the current user has no
36+
write access to the affected field. In this case use
37+
:ref:`User TSconfig level <userTsTcaDefaults>`.
38+
2639
.. note::
2740
`TCAdefaults` is not applied to :ref:`FlexForm <t3coreapi:flexforms>` values.
2841
These can only be addressed via :xml:`<default>` elements within the
2942
FlexForm data structure.
3043

44+
3145
.. _pageTsTcaDefaults-example:
3246

3347
Example: Do not hide newly created pages by default
@@ -37,3 +51,27 @@ Example: Do not hide newly created pages by default
3751
:caption: EXT:site_package/Configuration/page.tsconfig
3852
3953
TCAdefaults.pages.hidden = 0
54+
55+
.. _pageTsTcaDefaults-example-type:
56+
57+
Example: Set type specific default values
58+
=========================================
59+
60+
.. code-block:: typoscript
61+
:caption: EXT:site_package/Configuration/page.tsconfig
62+
63+
TCAdefaults.tt_content {
64+
header_layout = 1
65+
header_layout.types {
66+
textmedia = 3
67+
image = 2
68+
}
69+
70+
frame_class = default
71+
frame_class.types {
72+
textmedia = ruler-before
73+
image = none
74+
}
75+
76+
space_before_class = none
77+
}

Documentation/UserTsconfig/TcaDefaults.rst

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,29 @@
77
TCAdefaults
88
===========
99

10+
.. versionadded:: 14.0
11+
The :typoscript:`TCAdefaults` configuration has been extended to support
12+
type-specific syntax enabling different default values based on the record type.
13+
1014
This allows to set or override the `default` values of `TCA` fields that is available
11-
for various TCA types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.
15+
for various TCA column types, for instance for :ref:`type=input <t3tca:columns-input-properties-default>`.
1216

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

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

18-
#. Value from :php:`$GLOBALS['TCA']`
19-
#. Value from User TSconfig (these settings)
20-
#. Value from :ref:`Page TSconfig <pageTsTcaDefaults>`
23+
24+
#. Database field default value
25+
#. Value from `$GLOBALS['TCA']`
26+
#. Field-level ref:`user TSconfig <userTsTcaDefaults>`
27+
#. Type-level ref:`user TSconfig <userTsTcaDefaults>`
28+
#. Field-level :typoscript:`TCAdefaults` configuration
29+
#. Type-level :typoscript:`TCAdefaults` configuration
2130
#. Value from "defVals" GET variables
22-
#. Value from previous record based on 'useColumnsForDefaultValues'
31+
#. Value from previous record based on
32+
:ref:`useColumnsForDefaultValues <t3tca:ctrl-reference-usecolumnsfordefaultvalues>`
2333

2434
However the order for default values used by :php:`\TYPO3\CMS\Core\DataHandling\DataHandler` if a certain
2535
field is not granted access to for user will be:
@@ -62,3 +72,25 @@ of an extension:
6272
:caption: EXT:site_package/Configuration/TCA/Overrides/pages.php
6373
6474
$GLOBALS['TCA']['pages']['ctrl']['useColumnsForDefaultValues'] = 'doktype,fe_group';
75+
76+
.. _userTsTcaDefaults-example-types:
77+
78+
Example: Set type specific default values in user TSconfig
79+
==========================================================
80+
81+
.. code-block:: typoscript
82+
:caption: EXT:site_package/Configuration/user.tsconfig
83+
84+
TCAdefaults.tt_content {
85+
header_layout = 1
86+
# Use specific default values for certain types
87+
header_layout.types {
88+
textmedia = 3
89+
image = 2
90+
}
91+
}
92+
93+
In this example: If a user with no write access to the field `tt_content.header_layout`
94+
creates a new content element of type `textmedia` the header layout will be set
95+
to 3. If the user does have write access to the field, 3 will be used as default
96+
and they may change it.

0 commit comments

Comments
 (0)