Skip to content
Snippets Groups Projects
Commit 9b062f6f authored by Helmut Hummel's avatar Helmut Hummel Committed by Oliver Bartsch
Browse files

[BUGFIX] Prioritize form default values over TCA overrides

When defining a default value in column overrides
e.g. for tt_content TCA field sys_language_uid
this value from TCA will override the value that will
be set via the page module when adding a content
element for a different language, because the change
introduced in #86876 does not respect default values
that are set via defVals (which are passed to form engine
as defaultValues)

A check if such values are set is now added, so that
the fix for #86876 will still work, but default values set
via editing forms are also respected

Resolves: #99381
Releases: main, 11.5
Change-Id: Ib4270665b396bbe520afb21a7f145d0d549305ac
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/78893


Tested-by: default avatarcore-ci <typo3@b13.com>
Tested-by: default avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: default avatarOliver Bartsch <bo@cedev.de>
parent 75951ae8
Branches
Tags
No related merge requests found
......@@ -45,6 +45,7 @@ class TcaColumnsOverrides implements FormDataProviderInterface
if ($overridenDefault !== ''
&& !isset($result['userTsConfig']['TCAdefaults.'][$tableNameWithDot][$field])
&& !isset($result['pageTsConfig']['TCAdefaults.'][$tableNameWithDot][$field])
&& !isset($result['defaultValues'][$result['tableName']][$field])
&& ($result['databaseRow'][$field] ?? '') !== $overridenDefault
) {
$result['databaseRow'][$field] = $overridenDefault;
......
......@@ -136,4 +136,80 @@ class TcaColumnsOverridesTest extends UnitTestCase
self::assertEquals($expected, $this->subject->addData($input));
}
public static function addDataRespectsTSconfigDefaultValuesForNewRecordsDataProvider(): array
{
return [
[
[
'userTsConfig' => [
'TCAdefaults.' => [
'aTable.' => [
'aField' => 'userTsConfigValue',
],
],
],
],
],
[
[
'pageTsConfig' => [
'TCAdefaults.' => [
'aTable.' => [
'aField' => 'pageTsConfigValue',
],
],
],
],
],
[
[
'defaultValues' => [
'aTable' => [
'aField' => 'defaultValuesValue',
],
],
],
],
];
}
/**
* @test
* @dataProvider addDataRespectsTSconfigDefaultValuesForNewRecordsDataProvider
*/
public function addDataRespectsTSconfigDefaultValuesForNewRecords(array $result): void
{
$input = array_replace_recursive([
'command' => 'new',
'tableName' => 'aTable',
'vanillaUid' => 12,
'databaseRow' => [
'uid' => 42,
],
'recordTypeValue' => 'foo',
'processedTca' => [
'columns' => [
'aField' => [
'aConfig' => 'aValue',
],
],
'types' => [
'foo' => [
'showitem' => [],
'columnsOverrides' => [
'aField' => [
'config' => [
'default' => 'aDefault',
],
],
],
],
],
],
], $result);
self::assertNotTrue(isset($this->subject->addData($input)['databaseRow']['aField']));
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment