diff --git a/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php b/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php index 2d18336e93fba8dfe59718636e776eae43484156..9c2830591ffa349aa8ac57ff19de5fe6cdc407c1 100644 --- a/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php +++ b/typo3/sysext/core/Classes/Configuration/FlexForm/FlexFormTools.php @@ -654,7 +654,7 @@ class FlexFormTools ); } $fieldConfig['config']['maxitems'] = 1; - } elseif ($fieldConfig['config']['relationship'] === 'oneToMany') { + } else { // In case maxitems is not set or set to 0, set the default value "99999" if (!($fieldConfig['config']['maxitems'] ?? false)) { $fieldConfig['config']['maxitems'] = 99999; diff --git a/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php b/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php index 3f5ca9f2a7494bd8d2d99b488f28a55138eb63c7..e47eb09695129cf998e800c2e1223e36e22307d8 100644 --- a/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php +++ b/typo3/sysext/core/Classes/Configuration/Tca/TcaPreparation.php @@ -116,7 +116,9 @@ class TcaPreparation } elseif (!($fieldConfig['config']['maxitems'] ?? false)) { // In case maxitems is not set or set to 0, set the default value "99999" $fieldConfig['config']['maxitems'] = 99999; - } elseif ((int)($fieldConfig['config']['maxitems'] ?? 0) === 1) { + } elseif ($fieldConfig['config']['relationship'] === 'oneToMany' + && (int)($fieldConfig['config']['maxitems'] ?? 0) === 1 + ) { throw new \RuntimeException( $fieldName . ' of table ' . $table . ' is defined as type category with a ' . $fieldConfig['config']['relationship'] . ' relationship. Therefore, maxitems can not be set to 1. Use oneToOne as relationship instead.', diff --git a/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php b/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php index 72c4f14f5b6fc3ddfcc0bba5c0185fd78020af7e..c9214c653dc8fff7704ae21b5e0ead3d5415b02f 100644 --- a/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php +++ b/typo3/sysext/core/Tests/Unit/Configuration/Tca/TcaPreparationTest.php @@ -251,21 +251,6 @@ final class TcaPreparationTest extends UnitTestCase public static function configureCategoryRelationsThrowsExceptionOnInvalidMaxitemsDataProvider(): \Generator { - yield 'No relationship with maxitems=1 (falls back to manyToMany)' => [ - [ - 'aTable' => [ - 'columns' => [ - 'foo' => [ - 'config' => [ - 'type' => 'category', - 'maxitems' => 1, - ], - ], - ], - ], - ], - 1627335017, - ]; yield 'oneToOne relationship with maxitems=2' => [ [ 'aTable' => [ @@ -298,22 +283,6 @@ final class TcaPreparationTest extends UnitTestCase ], 1627335017, ]; - yield 'manyToMany relationship with maxitems=1' => [ - [ - 'aTable' => [ - 'columns' => [ - 'foo' => [ - 'config' => [ - 'type' => 'category', - 'relationship' => 'oneToMany', - 'maxitems' => 1, - ], - ], - ], - ], - ], - 1627335017, - ]; } #[Test]