TCA columnsOverrides ignores default value
Defining a differnet default value for a field in the 'types' array doesn't work.
For example it would be useful to set the default frame for a content element of type gridelement_pi1 to none. To do so the TCA might be overriden as following:
$columnsOverrides = ; $columnsOverrides['frame_class']['config'] = [ 'default' => 'none', ]; $GLOBALS['TCA']['tt_content']['types']['gridelements_pi1'] = array_merge( $GLOBALS['TCA']['tt_content']['types']['gridelements_pi1'], ['columnsOverrides' => $columnsOverrides] );
#3 Updated by Thomas Goetz 8 months ago
- Subject changed from TCA columnsOverrides default to TCA columnsOverrides ignores default value
- PHP Version set to 7.2
I have the same problem. I've defined the field `author` in tt_content table:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns( 'tt_content', [ 'author' => [ 'config' => [ 'type' => 'input', 'size' => 30, ], 'exclude' => '1', 'label' => 'Autor', ], ] );
I added this field to my own CE 'myext_quotation'.
When I add 'default' => 'Test' into the `addTCAcolumns`, it is perfectly working with my CE.
But now I override the filed for my CE `myext_quotation` like this:
$GLOBALS['TCA']['tt_content']['types']['myext_quotation'] = [ 'columnsOverrides' => [ 'author' => [ 'config' => [ 'type' => 'input', 'default' => 'Hallo', ], ], ], ];
When I now add a new element of this Type, the field has the value of the 'addTCAcolumns' block.
If i leave the default value initially empty and then override the filed it gets ignored.
#5 Updated by Daniel Siepmann 5 months ago
Same Issue for suggest wizard: #76661
There is already a patch attached. This should be the same in this case. There is a small piece of code missing, which merges the arrays.
I guess someone only has to find the accordingly place, we then could refactor the patch to provide a new method to merge the columnsOverrides and use this new method.
For Content Element Wizard, the default Value can already be added. See: https://docs.typo3.org/typo3cms/TSconfigReference/PageTsconfig/Mod.html#newcontentelement-wizarditems it's mod.wizards.newContentElement.wizardItems.[group].elements.[name].tt_content_defValues.
I'm not sure when default from TCA is applied, is it also applied if one changes the CType? Or is a field unchanged in that case? If so, it doesn't make sense to use default for tt_content depending on type I guess.