Readable form emails (forms.emailLayout)
{{*:table}} renders a readable submission summary (questions, option labels,
grouped by step, empty fields skipped) inside an email template with logo,
accent colour and footer from Site Settings → Emails. submitForm stores the
submission in the page language, so emails follow the visitor's locale.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -19,6 +19,8 @@ export type SubmitFormArgs = {
|
||||
formId: string
|
||||
/** Client IP — used for Turnstile and rate limiting. */
|
||||
ip?: string
|
||||
/** Page language — the form-builder reads the form (e-mail texts, labels) in it. */
|
||||
locale?: string
|
||||
/**
|
||||
* Rate limit: max submissions per IP per minute. Defaults to 5.
|
||||
* Set to 0 to disable (e.g. when a real limiter sits in front).
|
||||
@@ -96,6 +98,7 @@ export async function submitForm({
|
||||
data,
|
||||
formId,
|
||||
ip,
|
||||
locale,
|
||||
maxPerMinute = 5,
|
||||
payload,
|
||||
turnstileOnConfigError = 'allow',
|
||||
@@ -143,6 +146,7 @@ export async function submitForm({
|
||||
try {
|
||||
const submission = await payload.create({
|
||||
collection: 'form-submissions',
|
||||
...(locale ? { locale: locale as never } : {}),
|
||||
data: {
|
||||
form: formId,
|
||||
submissionData: Object.entries(validation.cleaned).map(([field, value]) => ({
|
||||
|
||||
Reference in New Issue
Block a user