Basics: what module-contact-form is
module-contact-form is the CCMS form module for incoming contact requests, with built-in client-side validation and Turnstile protection.
The module is designed for clear lead capture: you choose which fields are shown, which are required and which texts the user sees at every step.
The form is often used together with module-contact in the same section, but it can be configured on its own.
Option 1: core keys and field structure
The top level lives in contact_form, with keys such as module_type, display, appearance, aria_label, id, language, submit_button_text, success_message and error_message.
The field sections are:
text1,text2,text3email,phone,dropdown,file,textareatermsandmessages
Every visible field needs a language-neutral key in the default block. Use a semantic English camelCase key without spaces or underscores, for example firstName, lastName, company, email, phone, message, topic and attachment. Do not put key in the language variants.
Language variants follow the pattern <lang>_contact_form, for example en_contact_form, and translate the visible copy instead, such as label and placeholder. Labels are ordinary localised text and keep their spaces, for example What do you want to build?.
Option 2: enabling fields, required and validation
Each field block uses display to show or hide the field and can have name, key, label, placeholder, maxlength and required.
The build turns required into required_attr so the template can render the attribute consistently.
Client-side validation uses the browser's checkValidity() and reads its error texts from contact_form.messages.*, with variables such as {{max}} and {{min}}.
Option 3: terms, status flow and the file field
terms.display shows a terms line with a link. The content of terms.content_json is parsed at runtime and shown in a simple dialog/alert.
messages.* controls both validation errors and status steps such as status_precheck, status_robot, status_sending, status_done and status_timeout.
The file field can be shown in the UI, but the current runtime blocks actual file uploads and shows an information message on click instead.
Option 4: endpoint, Turnstile and the submit payload
The form is sent to the site’s own /api/forms. A page without a secure origin, such as file: or plain http:// outside your own computer, can’t send.
Before submitting, a fresh Turnstile token is fetched via ensureTurnstileToken(). The payload is sent as JSON with data, formId, language and the token in both the header and the body. The fields in data use the form <key>_<label>, where the localised label keeps its ordinary spaces.
For dropdowns, every language keeps the same stable machine value in value, while the visible option text is translated. Core sends the selected visible text in the payload that becomes the email content: <option value="annat">Other</option> therefore gives Other in the English email, while annat can stay as stable authoring structure.
After a successful submit, the form card is removed from the DOM and the user sees the success text in the status dialog.
Option 5: SEO, AI optimisation and data quality
Form copy should be concrete and specific to the visitor's intent: clear labels, clear placeholders and precise feedback on errors. That improves both conversion and how well AI understands what the page is for.
Translate every visible text in <lang>_contact_form, including messages.*, for a consistent experience in every language version.
The form module should not normally duplicate global schema data. Let the global structure carry the Organization/LocalBusiness signals instead.