Skip to content

Radio/checkbox: prefined default option stays checked when user submits a different value #1397

Description

@kitzberger

Component: Classes/ViewHelpers/Misc/PrefillMultiFieldViewHelper.php

Setup: a checkbox field with this setting:

one|1
two|2|*
three|3

So three options with option 2 being preselected.

How to reproduce:

  • select option 1
  • submit form
  • then
    • either trigger a validation error (so the form re-renders)
    • or come back from confirmation view (so the form re-renders)

Expected: only option 1 is checked.

Actual: options 1 and 2 are both checked.

Root cause: buildSelectedValue() chains prefill sources per-option with if (!$selected) guards. For option 2, all comparison methods (isFromMail, isFromMarker, …) return false (submitted 1 != 2), so the chain falls through to isFromPrefillValue(), which just returns the static * flag:

protected function isFromPrefillValue(): bool
{
    return (bool)$this->options[$this->index]['selected'];
}

It ignores whether the user already submitted a value for the field. Same flaw affects isFromTypoScriptContentObject/Raw and isFromSession. The sibling PrefillFieldViewHelper avoids this by resolving one field-level value with empty($value) guards.


TYPO3 13.
EXT:powermail 13.2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions