Skip to documentation content

Building and Handling Forms

Building and Handling Forms

How to display a form, handle validation, and process submission in Liquid templates.

Forms in Marketpath CMS are represented by the Form entity. To build and handle forms effectively in Liquid, you work with the form object, form fields, and the form submission flow.

Displaying a form: use the form object and its fields (and fieldsets, if applicable) to render the form markup. Each form field has a type (text, textarea, select, checkbox, etc.) and can be rendered with the appropriate HTML. You can use the element method or output field properties as needed. Form fields can be conditional and can have validators; see Form Field Conditions and Form Field Validators for how those are configured and how to respect them in your template.

When the user submits the form, the submission is processed by the system. Use the form_submit object (or equivalent) to determine whether the current request is a successful submission or a validation error. On success, you can show a thank-you message or redirect. On validation error, re-display the form so the user can correct their input; any validation messages or invalid field state should be shown so the user knows what to fix.

Keep the flow simple: one template can both display the form and handle the result by branching on the submission state (e.g. {% if form_submit.is_submitted %} ... {% else %} ... {% endif %}). For more detail, see the Form, form field, and form submit reference topics and the linked examples.