Bug #106697
closedTCA: Default record type is removed if (int) 0
100%
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
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
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
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
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
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
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
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
Updated by Georg Ringer about 1 month ago
- Status changed from Under Review to Resolved
- % Done changed from 0 to 100
Applied in changeset cbdd06b6b0a60a64c559aab9b5dfa10ebacd07ca.
Updated by Georg Ringer about 1 month ago
- Has duplicate Bug #106730: Type 0 is not recognized in backend TCA for records added
Updated by Oliver Bartsch 22 days ago
- Related to Bug #106789: Using itemsProcFunc for the record type field does not work added