Project

General

Profile

Actions

Bug #106697

closed

TCA: Default record type is removed if (int) 0

Added by Thomas Rawiel about 1 month ago. Updated about 1 month ago.

Status:
Resolved
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2025-05-14
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
13
PHP Version:
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

From this Bug report in EXT:news https://github.com/georgringer/news/issues/2641
I found, that this commit https://github.com/TYPO3/typo3/commit/0d81d8f43788ab40f73e9d4ea62923fa6addf293 introduced the following problem:

Staying with the example of EXT:news, there a 3 valid types (0,1,2)

However, the array_filter function in TYPO3\CMS\Backend\Form\FormDataProvider\DatabaseRecordTypeValue::getValidTypeValues() removes the record type with value 0

The result is, that the news record always shows the TCA showitem of for type 1, if the selected type is 0 or 1.

Test: Remove the array_filter()

protected function getValidTypeValues(array $items): array
{
    $test = array_map(static function (array $item) {
        $type = $item['value'] ?? '';
        return $type !== '--div--' ? $type : '';
    }, $items);

    $result_of_array_filter = array_filter($test);

    return $result_of_array_filter;
}

If we return $test early, the form is correct. Type 0 showitem is displayed.
If we return $result_of_array_filter the form shows the fields, that are configured in showitem for type 1

array_filter() removes values that are considered falsey by default — including 0 (integer), '' (empty string), false, and null

Possible solution:
add a callback to array_filter that explicitly checks for what you want to keep.

e.g.
$filtered = array_filter($array, function($value) {
return !empty($value) || $value === 0;;
});


Files

clipboard-202505141849-5lyma.png (19.8 KB) clipboard-202505141849-5lyma.png Thomas Rawiel, 2025-05-14 16:49

Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Bug #94408: Content element shows form fields for ctype text although it is not allowedResolved2021-06-24

Actions
Related to TYPO3 Core - Bug #106789: Using itemsProcFunc for the record type field does not workResolvedOliver Bartsch2025-05-28

Actions
Has duplicate TYPO3 Core - Bug #106709: The record type in the TCA ctrl section no longer works after the update to 13.4.11.Closed2025-05-15

Actions
Has duplicate TYPO3 Core - Bug #106708: Record type "0" not working in IRRE fields since 13.4.10Closed2025-05-15

Actions
Has duplicate TYPO3 Core - Bug #106730: Type 0 is not recognized in backend TCA for recordsClosed2025-05-19

Actions
Actions #1

Updated by Česlav Przywara about 1 month ago

  • Has duplicate Bug #106709: The record type in the TCA ctrl section no longer works after the update to 13.4.11. added
Actions #2

Updated by Česlav Przywara about 1 month ago

  • Has duplicate Bug #106708: Record type "0" not working in IRRE fields since 13.4.10 added
Actions #3

Updated by Georg Ringer about 1 month ago

  • Status changed from New to Accepted
Actions #4

Updated by Gerrit Code Review about 1 month ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89411

Actions #5

Updated by Oliver Hader about 1 month ago

  • Is Regression set to Yes
Actions #6

Updated by Oliver Hader about 1 month ago

  • Related to Bug #94408: Content element shows form fields for ctype text although it is not allowed added
Actions #7

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch main of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89411

Actions #8

Updated by Gerrit Code Review about 1 month ago

Patch set 1 for branch 13.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89437

Actions #9

Updated by Gerrit Code Review about 1 month ago

Patch set 2 for branch 13.4 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/89437

Actions #10

Updated by Georg Ringer about 1 month ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #11

Updated by Georg Ringer about 1 month ago

  • Has duplicate Bug #106730: Type 0 is not recognized in backend TCA for records added
Actions #12

Updated by Oliver Bartsch 22 days ago

  • Related to Bug #106789: Using itemsProcFunc for the record type field does not work added
Actions

Also available in: Atom PDF