- AGENT.md: "Ask before you build" (languages, styling, content, forms, analytics/consent, SEO/GEO, database + media, admin, hosting/DNS) — answers go to AGENTS.md "Project decisions", never guessed; "ipal-kit first" hard rule — a gap is reported to the owner and the agent waits for the decision, no hand-built replacements or silent workarounds; short "Code rules" (SRP, small files, no duplicates, typed, i18n texts, checks) pointing to §8 - ipal-setup stage 0 and ipal-site phase 0: the architecture question list, answered before building; content questions keep defaults - ipal-plugin-gap: report, offer options, wait, record the decision; ipal-block/collection/form/debug and vibe aligned; AGENTS.md template and the ipal-skills pointer block carry the rules - docsConsistency: the rules reach every site-building skill Co-Authored-By: Claude Opus 5.5 <[email protected]>
11 KiB
name, description
| name | description |
|---|---|
| ipal-form | Wires forms the ipal-kit way — forms built by the editor in the panel (form-builder Forms collection), one generic renderer, one server action with submitForm (rate limit, Turnstile, schema validation, GDPR consent), honeypot, panel texts from Notifications, emails from Forms → Emails over mailAdapter, GTM events from the panel. Use for any contact/lead/newsletter/quote form, a form block, "the form doesn't send", "no email arrives", spam, or Turnstile problems. |
ipal-form
ipal-kit first (hard rule, AGENT.md "ipal-kit first"): anything the plugin covers is built with the plugin's feature. It does not work or is not enough → report it with ipal-plugin-gap and wait for the owner's decision on that part; no hand-built replacement, no silent workaround. Code rules: AGENT.md "Code rules" (one job per file/component/function, no duplicates, typed, texts from the panel, a check for new behaviour).
The editor builds the form in the panel. The project has the action, a block with <RenderForm> and the classes. Every
further form — including multi-step ones and ones with choice lists — is panel work only. Fields/labels typed by hand in JSX = an error
(ipal-audit catches it). API details: docs/forms.md, turnstile.md, notifications.md, email.md.
1. Config (once per project)
// payload.config.ts
import { ipalKit, mailAdapter, buildFormAnalyticsFields } from '@intecion/ipal-kit'
export default buildConfig({
email: mailAdapter(), // without this, emails from Forms → Emails are not sent
plugins: [ipalKit({
i18n: i18nConfig,
forms: {
redirectRelationships: ['pages'],
formOverrides: { fields: ({ defaultFields }) => [...defaultFields, ...buildFormAnalyticsFields()] },
},
})],
})
@payloadcms/plugin-form-builder in the project's dependencies at the same version as
payload (a mismatch = no Forms collection). After a change: generate:types,
generate:importmap, restart.
2. Layout — Turnstile once
<SiteProviders shell={await getSiteShell(locale)}> in [locale]/layout.tsx (PROGRAMISTA §2.8)
wires TurnstileProvider with the key from the panel — always; never make the provider or the widget conditional.
Custom layout without SiteProviders: <TurnstileProvider siteKey={shell.turnstileSiteKey}> (turnstile.md).
Plugin behavior: both keys (panel or env) → the widget is visible and submitForm
requires a token (a bot cannot get around it by not sending one); no keys → no widget,
no verification, the form works; one key → off + an alert on the dashboard.
3. Code — import, not copy
The renderer, steps, validation, Turnstile, honeypot, redirect and GTM event live in the plugin. The project keeps three short files:
| File | Into the project | Role |
|---|---|---|
resources/actions.ts |
src/app/(frontend)/[locale]/actions.ts |
export const sendForm = createSubmitAction({ getCachedPayload, headers }) |
resources/FormBlock.tsx |
src/blocks/FormBlock/Component.tsx |
<RenderForm> from /rsc + project classes, inside <Section>/<SectionHeader> |
resources/formClasses.ts |
src/components/forms/formClasses.ts |
the only place for form styling (classes from DESIGN.md) |
resources/seed-form.template.ts |
scripts/seed-form-<name>.ts |
the form in the database: fields, confirmation, email to the company + to the customer, every language |
RenderForm (server) renders the "message" blocks and the confirmation via RenderRichText,
binds the action to the form and the language, resolves the redirect and sends only the
public part of the form to the browser (the Emails tab with the company addresses never reaches the HTML).
Underneath is BuilderForm (client) — clean, accessible HTML without styles: the look = classNames
(+ the data-ipal, data-type, data-width, data-step attributes).
Field types in the panel: text, email, textarea, number, date, time, select, radio (single choice),
checkbox, Checkbox group (multiple choice, min/max), message, Step (splits into steps),
country, state (on by default in form-builder, rendered as a text field).
Turning a type off: forms.fields: { country: false, state: false }.
- Multi-step form: the editor inserts a Step block (title, description) — the fields below it form one screen. The Next/Back buttons and "Step 1 of 3" come from Form messages → Form messages (next, back, stepOf). Next validates only the current step; a server error returns to the step with the field; focus moves to the new step. No Step = one screen.
width≤ 50 → classfieldHalf, otherwisefieldFull.
Unusual form (option cards instead of radios, a summary before sending, a custom field type, a slider): do not copy the engine — in this order:
renderFieldinBuilderForm(a'use client'file): replace chosen fields, the rest stay default (defaultRender()gives the original to wrap);- your own component on
useBuilderForm— full control over markup, same logic (resources/CustomForm.example.tsx):steps,step,next/back/goTo,submit,getInputProps / getTextareaProps / getSelectProps / getOptionProps,errors,TurnstileWidget. Field filled in by the page (selected product variant, category, offer): in the panel a plain text field (e.g.subject), in codeRenderForm values={{ subject }}; a value changed in the browser →prepareBuilderForm(server) +<BuilderForm values>(client). Never a copy ofpublicFormin the project (forms.md). Custom field type in the panel: theFormsOption['fields']type only acceptsbooleanfor known types (at runtime the block object passes through to form-builder, but TS rejects it), and the server treats an unknown type as text anyway — if you need a custom type or validation → plugin gap (ipal-plugin-gap).
4. Page — block data once (blocks do not import lib/*)
From createPageRoute (PROGRAMISTA §2.8):
const route = createPageRoute(content, {
blocks: blockRegistry, notFound, permanentRedirect,
blockProps: async ({ locale }) => ({ formTexts: await content.getFormTexts(locale), sendForm }),
})
Custom page: the same in enhanceProps (formTexts from getFormTexts(locale), sendForm from actions.ts).
Page query: depth ≥ 1 (the form relationship as an object). Block registry:
formBlock: FormBlock. A form outside a block (footer, modal) = the same <RenderForm>
with the form from a relationship in a global, never a copy.
5. Form in the database — ALWAYS via a seed (resources/seed-form.template.ts)
Every form from the brief is created by a script, not by hand: that makes it repeatable (dev → production), it has every language and both emails, which are easy to forget:
- notification to the company:
emailTo= address from the panel (company global),replyTo: {{email}}, body{{*:table}}; - confirmation to the customer:
emailTo: {{email}},replyTo= company address, subject and body per language.
cp .agents/skills/ipal-form/resources/seed-form.template.ts scripts/seed-form-contact.ts
# fill FORM from the brief (fields, labels, messages, email subjects — every language), NOTIFY = global/field with the company address
pnpm payload run scripts/seed-form-contact.ts
The template writes the form with createSeeder(...).upsertBy('forms', { title }, data) from
@intecion/ipal-kit/seed (every language, row ids kept, edited forms skipped).
Without a notification address the script stops — ask the client which inbox should receive
submissions (a question from the list in ipal-site), enter it in the panel and run again. Never put the address in code.
Commit the script — in production run it after the migration: SEED_DRY_RUN=1 first, back up the database, then
the real run (rules: node_modules/@intecion/ipal-kit/docs/seeding.md). Changing the form: fix FORM,
SEED_UPDATE=1 pnpm payload run … — it updates the form only if nobody edited it since seeding (otherwise
skip (edited)); on production / a non-local database it also needs IPAL_SEED_ALLOW_PROD_UPDATE=1.
Details the seed already covers, which you check after every manual change in the panel:
- Forms → the form: fields from the brief,
namein English, lowercase (name,email,phone,message,consent); labels per language. - GDPR consent: a
consentcheckbox, a label with a link to the policy, not ticked by default (the plugin enforces it server-side anyway →reason: 'consent'). - Confirmation: a message (per language) or a redirect to a "Thank you" page
(then that page gets
noindex). - Emails: notification to the company (
emailTofrom the company global/panel,replyTo: {{email}}, body{{*:table}}) and confirmation to the sender (emailTo: {{email}}) — both mandatory. The email field must havename: 'email'(the plugin accepts exactly one address in it). - Analytics (GTM / dataLayer): Event name
generate_lead/form_submit, parametersform_name. - Site integrations: mail transport (SMTP/Graph) + Send test; Turnstile keys.
- Form messages → form.*: texts in every language.
6. Check it yourself before you say "done"
- submitting with empty required fields → errors at the fields, no request;
- a valid submission → confirmation, a record in Form Submissions, the email to the company arrived and the confirmation arrived at the address entered in the form (Send test in the panel works = transport OK; still no email → the form's Emails tab);
- unticked consent → a message from Notifications (not the English fallback);
- 6 quick submissions →
rate_limited; - Turnstile with keys → widget visible; submitting without solving the widget →
turnstile; wrong secret → the form goes through, and the panel (dashboard + Site integrations → Turnstile) shows a red alert; - Turnstile without keys → no widget, the form goes through;
- second language → labels and messages in that language;
- GTM Preview → an event with the name from the panel after success;
- multi-step form: Next with an empty step → errors, the step stays; Back keeps the entered values;
ipal-audit --quick→ zero hardcoding in FormBlock, no copy of the form engine;ipal-consent-check→ still 0 violations (Turnstile is necessary, not tracking).
Diagnostics
| Symptom | Cause → fix |
|---|---|
| no Forms collection in the panel | form-builder vs payload version mismatch → same version, pnpm.overrides |
| the block renders nothing | form is an ID (depth too low) or formTexts/sendForm missing in enhanceProps |
reason: 'validation', kind: 'unknown_fields' |
the frontend sends a field the form does not have (custom renderer with an extra field, typo in name) |
| "Next/Back" buttons in English | empty Form messages → next / back / stepOf in that language |
reason: 'not_found' |
formId from another database (seeded on dev, another ID on prod) — use a relationship from the panel, not a fixed ID in code |
| submission exists, no email | missing email: mailAdapter(), empty Emails tab, transport in the panel; server logs |
always turnstile |
wrong key pair / domain in Cloudflare (BuilderForm resets the token after an error) |
the page became dynamic (ƒ) |
headers() in a component instead of in the action |
| messages in English | empty Notifications in that language |