Skip to content

[6.x] Forms 2: Autocomplete editor for email subject and message - #15647

Open
jasonvarga wants to merge 6 commits into
forms-2from
forms-2-autocomplete
Open

jasonvarga wants to merge 6 commits into
forms-2from
forms-2-autocomplete

Conversation

@jasonvarga

@jasonvarga jasonvarga commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

The Email connector's Subject and Message fields now use the autocomplete_editor fieldtype. Type @ to insert [[ handle ]] mentions for submitted values, site values, registered values and globals.

Mention sources

  • Form fields that collect a value, in blueprint order.
  • form.title, plus site.name and site.url (absolute), from the submission's form and site.
  • Values registered with Form::registerMention('app.name', 'App Name', fn () => config('app.name')). Closures receive the submission. Core registers app.name. Handles must contain a dot so they can't collide with form field handles, and the form., site. and globals. prefixes are reserved.
  • Globals as globals.{set}.{field}, localized to the submission's site. Fieldtypes that don't make sense as text are excluded, e.g. bard, replicator, grid and relationship fieldtypes.

Form fields are listed first. Everything else is sorted by label. Values are only resolved for mentions that actually appear in the content, so registered closures and global sets aren't touched unless they're referenced.

Subject

The subject uses plain-text mode, so existing Antlers subjects load unchanged and still work. Mentions are resolved with Mentions::replace(..., using:), which means submitted values are never parsed as Antlers.

Message

The message is markdown with mentions only, and no Antlers. Running Antlers before markdown would let submitted values inject HTML or markdown (e.g. links) into site emails. It's rendered with AutocompleteEditor::renderHtml(), which escapes each value. The message field is new in Forms 2, so there's nothing to stay compatible with.

Reusable helpers

Statamic\Forms\SubmissionMentions provides options(), values(), handlesIn() and replace(). replace() renders content in a single call, so it also works from queued jobs. The Connector base class gets mentionOptions() for field config. Other connectors (e.g. forms-pro's Slack/Twilio) can offer the same mentions.

🤖 Generated with Claude Code

jasonvarga and others added 6 commits October 14, 2026 13:03
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sage

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ion prefixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…replace() helper

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant