A contact form in a few lines
Describe the fields, place the form on a page, done. Messages arrive in your inbox — no form service, no JavaScript, no database.
What is the contact form module?
A contact form for your ForgeCMS website that you describe in a few lines instead of programming it. ForgeCMS builds the form, checks the input and sends every message to your inbox. You answer with your normal mail program — the reply goes straight to the sender.
Try it live: our contact page uses exactly this module.
Which fields?
- Text, email and phone — single-line fields; email addresses are checked.
- Text area — for longer messages.
- Checkboxes — a single box (e.g. "I have read the privacy policy") or several to choose from.
- Radio buttons — exactly one of several options.
- Selection list — a drop-down with your options.
- Newsletter opt-in — a "Yes, send me the newsletter" box, together with the newsletter module.
Any field can be required. If something is missing, the visitor sees what and keeps everything already typed.
Safe and simple
- No form service and no JavaScript: the form works in every browser.
- Protection against spam bots and floods of messages, without annoying puzzles.
- Messages are only mailed, not stored on the web server.
- Your own texts for the button and the thank-you message, in every language of your site.
1. Describe the fields
In the site configuration (app.sml) you list the fields once. Every field has a name, a type and a label; required: true makes it mandatory.
Contact {
to: "hello@my-bakery.com"
subject: "Message from the website"
success_message: "Thank you! We will get back to you soon."
Field { name: "name" type: "text" label: "Name" required: true }
Field { name: "email" type: "email" label: "Email" required: true }
Field { name: "phone" type: "tel" label: "Phone" }
Field { name: "topic" type: "radio" label: "Topic"
options: "Order, Catering, Other" }
Field { name: "days" type: "checkbox" label: "Pick-up days"
options: "Tue, Wed, Thu, Fri, Sat" }
Field { name: "size" type: "select" label: "Party size"
options: "up to 10, 10–30, more than 30" }
Field { name: "text" type: "textarea" label: "Message" required: true }
Field { name: "privacy" type: "checkbox" required: true
label: "I have read the privacy policy" }
Field { name: "news" type: "newsletter" }
}2. Place the form on a page
The form can go on any page, e.g. next to your address or a map.
Page {
title: "Contact"
Heading { level: "1" text: "Write to us" }
ContactForm { submit: "Send message" }
}Several languages
Every label and every option list can be translated: add the language code to the property.
Field { name: "topic" type: "radio"
label: "Thema" label_en: "Topic"
options: "Bestellung, Catering, Sonstiges"
options_en: "Order, Catering, Other" }