diff --git a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsOverrides.php b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsOverrides.php index 63d6a3833c4151e4abd0814dfec04661f1071560..0eae906fd1f8351697867f8255458526acaa7e99 100644 --- a/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsOverrides.php +++ b/typo3/sysext/backend/Classes/Form/FormDataProvider/TcaColumnsOverrides.php @@ -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; diff --git a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaColumnsOverridesTest.php b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaColumnsOverridesTest.php index b2b6c5811078ace235b5ab1c2e6b773d69646f5f..837cae8ad65dd4f625f2bb2eadddf85db302da01 100644 --- a/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaColumnsOverridesTest.php +++ b/typo3/sysext/backend/Tests/Unit/Form/FormDataProvider/TcaColumnsOverridesTest.php @@ -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'])); + } }