#101521DataHandler doesn't update value of "radio" element if item value is empty string
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.
Reviews 1
Files 1
History 4
-
Benni Mack changed Sprint Focus On Location Sprint 08/02/23, 14:41
-
Bastien Lutz commented 05/05/25, 19:56
-
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?
-
Benni Mack commented and changed status
NewClosed 05/06/25, 08:40Thank you, closing the issue.
I am taking a look at it.