Repository navigation
[6.x] Forms 2: Autocomplete editor for email subject and message - #15647
Open
jasonvarga wants to merge 6 commits into
Open
jasonvarga wants to merge 6 commits into
jasonvarga wants to merge 6 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Email connector's Subject and Message fields now use the
autocomplete_editorfieldtype. Type@to insert[[ handle ]]mentions for submitted values, site values, registered values and globals.Mention sources
form.title, plussite.nameandsite.url(absolute), from the submission's form and site.Form::registerMention('app.name', 'App Name', fn () => config('app.name')). Closures receive the submission. Core registersapp.name. Handles must contain a dot so they can't collide with form field handles, and theform.,site.andglobals.prefixes are reserved.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\SubmissionMentionsprovidesoptions(),values(),handlesIn()andreplace().replace()renders content in a single call, so it also works from queued jobs. TheConnectorbase class getsmentionOptions()for field config. Other connectors (e.g. forms-pro's Slack/Twilio) can offer the same mentions.🤖 Generated with Claude Code