Implements frontend forms and actions in Kirby (contact forms, file uploads, email with attachments, creating pages from frontend). Use when handling user input or building submission flows.
name: kirby-forms-and-frontend-actions
description: Implements frontend forms and actions in Kirby (contact forms, file uploads, email with attachments, creating pages from frontend). Use when handling user input or building submission flows.
Store files under a dedicated page (e.g. page('uploads')) or the current page.
Normalize filenames and enforce MIME/size limits before saving.
Common pitfalls
Missing CSRF verification on POST handlers.
Accepting uploads without MIME or size checks.
Workflow
Clarify the form type, validation rules, spam protection, storage target, and email requirements.
Call kirby:kirby_init and read kirby://roots.
Inspect existing templates/controllers/snippets for patterns:
kirby:kirby_templates_index
kirby:kirby_controllers_index
kirby:kirby_snippets_index
Read relevant config options via kirby://config/{option} (e.g. email, routes) when needed.
Search the KB with kirby:kirby_search (examples: "basic contact form", "frontend file uploads", "email with attachments", "creating pages from frontend").
Implement controller-driven validation and CSRF checks; keep templates thin and escape output.
For uploads, enforce MIME/size limits and store files in safe locations.
Verify by submitting forms in a browser and rendering success/error states with kirby:kirby_render_page.