Project

General

Profile

Actions

Bug #101521

open

DataHandler doesn't update value of "radio" element if item value is empty string

Added by Felix Heller over 1 year ago. Updated over 1 year ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
DataHandler aka TCEmain
Target version:
-
Start date:
2023-08-01
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
11
PHP Version:
8.0
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
On Location Sprint

Description

I've created a radio element with two items, one with the value "active" and one with the value "" (empty string). After setting the value to "active" and saving the entity in the TYPO3 backend, I cannot set the value to "" because it isn't updated correctly:

This is the TCA configuration of the example element:

'config' => [
    'type' => 'radio',
    'items' => [
        ['Active', 'active'],
        ['Inactive', ''],
    ],
],

I think the problem is located in the function checkValueForRadio($res, $value, $tcaFieldConf, $table, $id, $pid, $field) in \TYPO3\CMS\Core\DataHandling\DataHandler. After submitting the form with the radio button set to the empty the, the variable $value has the value 'on' and not '' as expected. The function loops through the definition of items in the TCA and tries to find a match for the $value, but it fails in this case because 'on' and '' are not equal and thus the field value is not updated to '' in the database.

A simple workaround is to avoid an empty value for 'items' but I think this issue should be checked and fixed.


Files

example-status-inactive.png (13.1 KB) example-status-inactive.png Felix Heller, 2023-08-01 12:28
Actions

Also available in: Atom PDF