Bug #86164
closedCheckboxViewHelper sets automatically each checkbox on checked, if just one of them is checked
100%
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)