Issue Bug Closed

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

Felix Heller 08/01/23, 12:46 updated 05/06/25, 08:40

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:

example-status-inactive.png

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.

Reviews 1

Files 1

History 4

  1. Benni Mack changed Sprint Focus On Location Sprint 08/02/23, 14:41

  2. Bastien Lutz commented 05/05/25, 19:56

    I am taking a look at it.

  3. Bastien Lutz commented 05/05/25, 21:37

    As i can see this was fixed since version 12 with this patch: https://review.typo3.org/c/Packages/TYPO3.CMS/+/81645

    I think therefore this issue can be closed?

  4. Benni Mack commented and changed status New Closed 05/06/25, 08:40

    Thank you, closing the issue.