Bug #101521
openDataHandler doesn't update value of "radio" element if item value is empty string
0%
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