Skip to content

Add support for Forms 2 - #126

Open
duncanmcclean wants to merge 7 commits into
aerni:mainfrom
duncanmcclean:forms-2-support
Open

duncanmcclean wants to merge 7 commits into
aerni:mainfrom
duncanmcclean:forms-2-support

Conversation

@duncanmcclean

@duncanmcclean duncanmcclean commented Oct 14, 2026 •

Copy link
Copy Markdown

This pull request updates the addon to support the upcoming Forms 2 changes in Statamic Core, while staying compatible with current Statamic versions, so it shouldn't need a breaking release.

As this is quite a popular addon, I wanted to open a PR to give you a head start on supporting the new features.

What's changing in Core?

We're overhauling forms — forms get a dedicated form builder with a bunch of new form-specific fieldtypes (star_rating, opinion_scale, ranking, image_choice, group, etc.), and submissions now run through a new SubmitForm action which handles validation, spam, restrictions, file uploads, events and emails in one place.

The new fieldtypes cause an error when rendering a form with this addon, hence this PR.

What's in this PR?

  • Field models, config bindings and default views for the new fieldtypes. Form fieldtypes are thin wrappers around "real" fieldtypes — that way, we can offer form-friendly options in the Form Builder while reusing the existing fieldtypes under the hood. When a form's blueprint is compiled, each field resolves to its underlying fieldtype, e.g. short_answer compiles to text. Some of the underlying fieldtypes are new classes extending existing ones, so field models now fall back to the binding of their closest parent class, e.g. yes_no resolves to the Radio model.
  • Submissions are handled by Core's new SubmitForm action when it exists, so they behave exactly like native Statamic submissions. On older Statamic versions, the existing submission flow is used instead — you'll probably want to drop the old flow in your next major version.
  • A new test suite covering the new fieldtypes and submission flow. This needed two small tweaks to the TestCase: blueprint deletion is null-safe now, since forms no longer have dedicated blueprint files, and the Statamic facade alias is registered, since the toggle view uses it and the new tests render every fieldtype.

I've deliberately kept this to the minimum needed to make everything work — no new features, no unrelated refactoring. Obviously feel free to change whatever you like, and DM me if you have any questions!

Testing it out

You can test this against Forms 2 using the forms-2-preview branch of statamic/cms, which contains the built assets — no need to compile anything:

composer require "statamic/cms:dev-forms-2-preview as 6.35.1" -w

Forms 2 should be considered alpha right now — things are highly likely to change, so only use it locally for testing.

duncanmcclean and others added 7 commits September 2, 2026 13:14
forms 2 hasn't shipped yet, so this points at the `forms-2` branch of statamic/cms for now, aliased as `6.31.0` so dependency constraints keep resolving. also sorts the `require` block alphabetically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATXH2uZVrsXqYrGqUoKhQA
forms no longer have dedicated blueprint files, so blueprint deletion in the tests needs to be null-safe. the `Statamic` facade alias is also registered for the test app, as testbench doesn't register it and the toggle view relies on it.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATXH2uZVrsXqYrGqUoKhQA
when a fieldtype has no model binding of its own, fall back to the binding of its closest parent class. this lets subclassed fieldtypes, like forms 2's `YesNo` extending `Radio`, resolve without needing a binding of their own.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATXH2uZVrsXqYrGqUoKhQA
adds models, config bindings, and default views for the fieldtypes introduced by forms 2: `date_picker`, `time_picker`, `star_rating`, `opinion_scale`, `ranking`, `image_choice`, `upload`, `group`, `heading`, `paragraph`, and `banner`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATXH2uZVrsXqYrGqUoKhQA
when the `SubmitForm` action exists, submissions are handled by statamic itself so spam protection, restrictions, file uploads, events, and emails behave exactly like a native form submission. validation errors are mapped back to their livewire error keys, and restricted forms surface their message as a form-level error. older statamic versions continue to use the addon's own submission flow.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATXH2uZVrsXqYrGqUoKhQA
covers rendering and field model resolution of the new fieldtypes, persisting submissions, file uploads, restrictions, event isolation between forms submitted in the same request, and validation error mapping.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATXH2uZVrsXqYrGqUoKhQA
@aerni

aerni commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Thanks, Duncan. Really appreciate this PR!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants