Project

General

Profile

Actions

Bug #102303

closed

Empty radio elements are saved as "on"

Added by Robert Vock about 1 year ago. Updated 5 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
FormEngine aka TCEforms
Target version:
-
Start date:
2023-11-02
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
12
PHP Version:
Tags:
Complexity:
Is Regression:
Yes
Sprint Focus:

Description

When the radio (or select) entry contains an empty value, this value will be saved as "on" in TYPO3 v11. In TYPO3 v10 it was the empty string.

Example Flexform-Configuration:

<settings.size>
    <TCEforms>
        <label>Größe</label>
        <config>
            <type>radio</type>
            <items>
                <numIndex index="0">
                    <numIndex index="0">Groß</numIndex>
                    <numIndex index="1"></numIndex>
                </numIndex>
                <numIndex index="1">
                    <numIndex index="0">Mittel</numIndex>
                    <numIndex index="1">medium</numIndex>
                </numIndex>
                <numIndex index="2">
                    <numIndex index="0">Klein</numIndex>
                    <numIndex index="1">small</numIndex>
                </numIndex>
            </items>
        </config>
    </TCEforms>
</settings.size>

If the user chooses the first option (Groß), then "on" is saved and when the form is presented again, no option is selected.
When a class or template checks, if settings.size is empty, it would return true in TYPO3 v10 and returns false in TYPO3 v11, because "on" is saved.

The error was introduced in #91787
https://github.com/TYPO3/typo3/commit/757f82d1240497500165435c1db7bdf9e15a48a7#diff-d0d979ea8e3e22f10cbeb8385f2c3812d775ca558f4de30a4b22bf6ce7e0e017

Instead of building the attributes itself, the method now uses GeneralUtility::implodeAttributes, but without the keepBlankAttributes=true parameter. This leads to empty value-attributes being dropped and the browser saves radio-buttons without a value attribute as "on".

The fix would be easy: Add the keepBlankAttributes=true parameter.

Actions

Also available in: Atom PDF