Skip to content

Fix: Form Builder: Display validation error on the submitted form only - #1212

Draft
n7studios wants to merge 3 commits into
fix-form-builder-name-fieldfrom
fix-form-builder-multiple-forms-validation
Draft

n7studios wants to merge 3 commits into
fix-form-builder-name-fieldfrom
fix-form-builder-multiple-forms-validation

Conversation

@n7studios

@n7studios n7studios commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the Form Builder block displaying a validation error on every Form Builder block on a Page, and jumping to the first block, when a visitor submits a form further down the Page.

The submission error was stored once per request, and every Form Builder block on the Page added the error notice and autofocus attribute, so the browser focused the first block. This was reported by a creator with two Form Builder blocks on their homepage: submitting the second block with an invalid email address jumped back to the first block's error.

Each block now outputs its index on the Page as a hidden convertkit[block_index] field. The error notice, aria-invalid and autofocus are only added to the block that was submitted, so the visitor is taken to that block and its error. If no index is submitted (e.g. a page cached before this update), the error is displayed on all blocks, as before.

Testing

New Integration tests in BlockFormBuilderMultipleFormsTest:

  • testBlockIndexHiddenField: each block outputs its index. Fails without this fix.
  • testErrorDisplayedOnSubmittedBlockOnly: the error notice, aria-invalid and autofocus are only added to the submitted block. Fails without this fix.
  • testErrorDisplayedOnAllBlocksWhenNoBlockIndex: the existing behaviour is kept when no index is submitted.

New E2E test, PageBlockFormBuilderCest::testFormBuilderBlockWithInvalidEmailAddressInSecondBlock:

  • Adds two Form Builder blocks to a Page and submits the second with an invalid email address.
  • Confirms one error notice is displayed, in the second block.
  • Confirms the second block's email field is focused.

Checklist

@n7studios n7studios added this to the 3.4.6 milestone Oct 2, 2026
@n7studios n7studios self-assigned this Oct 2, 2026
@n7studios n7studios added the bug label Oct 2, 2026
@n7studios n7studios changed the title Form Builder: Support Multiple Forms Oct 2, 2026
@n7studios
n7studios changed the base branch from main to fix-form-builder-name-field October 2, 2026 03:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant