Appearance
form
Renders a <form> element with CSRF protection and appropriate action routing. Four form types are supported.
When used within a Syngency theme, see the Forms page for usage details including conditional fields, testing and validation.
Usage
liquid
{% form 'type' %}
<!-- form fields -->
{% submit form: 'type', class: 'btn' %}Submit{% endsubmit %}
{% endform %}Form types
| Type | Description |
|---|---|
contact | Sends an email to the agency contact address |
submission | Creates a new model record in a specified division |
password | Sets a session password for basic page protection |
package | Handles package form submission |
contact
{% form 'contact' %} ... {% endform %}
Sends an email on submission. Recipient defaults to {{ agency.email }} (as defined in Settings > General).
Often also used as a submission form when the agency doesn't want model records created from submissions.
Required fields
name, email, message
Template variables
The following querystring parameters are appended after submission:
querystring.sent— set to1on successful submissionquerystring.form.errors— array of validation errors if submission failedquerystring.form.values— array of field values
Re-populating fields
Unless using Syngency's custom Liquid field tags, use querystring.form.values to restore submitted values after a failed submission:
liquid
<input name="first_name" value="{{ querystring.form.values.first_name }}">
<select name="date_of_birth[month]">
<option value="january"{% if querystring.form.values.date_of_birth.month == 'january' %} selected{% endif %}>January</option>
</select>Example
liquid
{% if querystring.sent %}
<p>Your message has been sent.</p>
{% else %}
{% if querystring.form.errors %}
<ul>{{ querystring.form.errors }}</ul>
{% endif %}
{% form 'contact' %}
<input type="hidden" name="subject" value="New message from the Agency website">
<input type="hidden" name="send_to" value="someone@agency.com">
<input type="text" name="name" required>
<input type="email" name="email" required>
<textarea name="message" required></textarea>
{% submit form: 'contact', class: 'btn' %}Send{% endsubmit %}
{% endform %}
{% endif %}submission
{% form 'submission' %} ... {% endform %}
- Creates a new model record in a specified division.
- Sends a fixed-format agency notification email. Recipient defaults to
{{ agency.email }}(as defined in Settings > General). - Sends an acknowledgement email to the
emailentered into the form. Email content is configured in Settings > Templates > Model Submission.
Required hidden fields
html
<input type="hidden" name="is_published" value="0">
<input type="hidden" name="division_id" value="YOUR_DIVISION_ID">WARNING
If division_id is omitted, the submission will fail silently — no error will be shown and no record will be created.
Template variables
The form object will have the following properties available after submission:
form.posted_successfully?— boolean,trueif the record was created successfullyform.errors— array of validation errors if submission failedform.values— array of field values
Re-populating fields
Unless using Syngency's custom Liquid field tags, use form.values to restore submitted values after a failed submission:
liquid
<input name="first_name" value="{{ form.values.first_name }}">
<select name="date_of_birth[month]">
<option value="january"{% if form.values.date_of_birth.month == 'january' %} selected{% endif %}>January</option>
</select>Example
liquid
{% if form.posted_successfully? %}
<p>Thank you for your submission.</p>
{% else %}
{% if form.errors %}
<ul>{{ form.errors }}</ul>
{% endif %}
{% form 'submission' %}
<input type="hidden" name="is_published" value="0">
<input type="hidden" name="division_id" value="1234">
<input type="text" name="first_name">
<input type="text" name="last_name">
<input type="email" name="email">
{% submit form: 'submission', class: 'btn' %}Apply{% endsubmit %}
{% endform %}
{% endif %}password
{% form 'password' %} ... {% endform %}
Sets a session value used for basic page or division protection. The submitted password is stored in the session and made available as the password variable in templates.
The expected password and any restrictions are defined directly in the template using {% assign %}.
Template variable
password— the current session password value
Example
liquid
{% assign passwordValue = 'chickensandwich' %}
{% if password != passwordValue %}
{% form 'password' %}
<input type="password" name="password" placeholder="Enter password">
<button type="submit">Submit</button>
{% endform %}
{% else %}
<!-- protected content -->
{% endif %}INFO
This is basic protection only intended for password-protected divisions / models. An agency's clients are expected to all share the same password. It is not a substitute for real authentication.
When password-protecting divisions, consider whether access needs to be restricted in the division, model, and search templates.
package
{% form 'package' %} ... {% endform %}
Handles package form submission. Sends a notification email to the agency.
Only requires a message field.
Expected to be used on a Package template, often in conjunction with Syngency Package selection & comment features.
Example (in Package template)
liquid
{% if recipient %}
{% form 'package' %}
{% if form.posted_successfully? %}
<h3>Thank you, your selection has been sent.</h3>
{% else %}
<textarea name="message" placeholder="Message to agent"></textarea>
<button type="submit" class="btn btn-primary">Submit to agency</button>
{% endif %}
{% endform %}
{% endif %}Field tags
Syngency provides custom field tags {% input %}, {% select %}, {% textarea %}, and {% upload %} which automatically re-populate with submitted values on refresh, e.g. after failed submission with errors.
If using standard HTML fields, values must be re-populated manually using the appropriate form variables.
Options
| Option | Type | Description |
|---|---|---|
send_to | string | Overrides the default recipient email. Applies to contact, submission, and package. Defaults to {{ agency.email }} |
subject | string | Overrides the default subject. |
test | 1 | Adding this field forces the form to dump the POST data in the browser on submit, instead of processing. |
Output
Renders a <form> element with:
actionset to/<type>(preserving any existing querystring parameters)class="<type>-form"andid="<type>-form"- A hidden CSRF token field injected automatically
Notes
- CSRF protection is automatically included — a hidden token field is injected into every form. Do not add it manually.
- Spam prevention is automatically included within the
{% submit %}tag. - Querystring parameters present on the page when the form is rendered are preserved in the form action URL.
- Page reloads on submission — there is no redirect. Success and error states are communicated via template variables on the reloaded page.