Issue Bug Closed

#86164CheckboxViewHelper sets automatically each checkbox on checked, if just one of them is checked

Julian Stelzer 09/06/18, 11:42 updated 05/07/19, 12:17

Description

If you want to use more than one checkbox in your form, for example a choice of categories in a simple FE-search and you set them like this.

<f:for each="{suche.options}" as="option" key="value">

     <f:form.checkbox property="category" multiple="true" value="{value}" id="check_{value}" />

  </f:for>

After you sent the form via POST just your selected checbox should be marked (checked=“checked”), but instead all checkboxes after your last marked checkbox are marked too.

E.g.
______________________________________
Your Search word: Example

cat 1 []
cat 2 [x]
cat 3 []
cat 4 []

-> you send this, but after reload with the values

Your Search word: Example

cat 1 []
cat 2 [x]
cat 3 [x]
cat 4 [x]

-> cat 2-4 are marked too.
________________________________________

The problem seems to be the CheckBoxViewHelper. The following code doesn’t remove the checked tag from the next checkboxes.

if ($checked === true) {
            $this->tag->addAttribute('checked', 'checked');
        }

So if I add the else-case, it works as it should.

        if ($checked === true) {
            $this->tag->addAttribute('checked', 'checked');
        }
        else {
            $this->tag->removeAttribute( 'checked');
        }

The bug was first located in TYPO3 9.3 ( I don’t know, if it was there earlier)

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.