Skip to content

"An invalid form control is not focusable" on multi-step forms with mandatory conditional checkbox groups #128

Description

@kitzberger

When a powermail multi-step form contains a mandatory checkbox group (multiple checkboxes sharing name="…[]") that is conditionally hidden/shown by EXT:powermail_cond, submitting the form after checking a non-first checkbox of that group produces a browser console error:

An invalid form control with name='tx_powermail_pi1[field][<marker>][]' is not focusable.

and blocks form submission.

Root cause:

Two bugs in PowermailConditions.js:

  1. #getFieldByMarker returns only the first checkbox. It uses querySelector (singular), so #hideField/#showField only disable/enable and derequire/rerequire the first checkbox of a multi-value group. The remaining checkboxes keep their validation state unchanged.
  2. #rerequireField converts data-powermail-required to native required. Powermail renders multi-checkbox mandatory fields with data-powermail-required="true" (not native required) and handles "at least one checked" via data-powermail-multiple. The old #rerequireField unconditionally restored a native required attribute, which the browser's reportValidity() (called by #submitListener) then tried to enforce. In a multi-step form the field's fieldset is display:none (hidden by the morestep navigation), so the browser cannot focus the invalid checkbox and emits the "not focusable" error.

Trigger conditions (all required):

  • Multi-step form (moresteps=1) with 2+ pages
  • Mandatory checkbox group on a non-final step, conditionally hidden by powermail_cond
  • Powermail JS validation active (data-powermail-validate)
  • User checks a non-first checkbox of the shown group, then navigates to the next step and submits

Fix:

  • #hideField/#showField: iterate querySelectorAll('input, select, textarea') over the wrapping container so all inputs in a multi-value group are disabled/enabled and derequired/rerequired.
  • #derequireField/#rerequireField: bookmark which attribute was present (required or data-powermail-required) and restore the same one, preserving powermail's custom validation mechanism for multi-checkbox groups.

TYPO3: 13
Powermail: 13.1.0
Powermail Cond: 13.1.2

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