What We'll Cover
To add a contact form to your LemonStand website, you will add code for the contact form to any page you want it to appear. You could also add it to a partial, and then call this partial from a template, page and content block.
Contact forms use the system:onSendMessage
AJAX handler. Here's an example of a simple contact form:
{{ open_form({'data-ajax-handler': 'system:onSendMessage'}) }}
<div class="row">
<div class="twelve columns">
<label for="contact_email">E-mail Address *
<input type="text" id="contact_email" name="fields[email]" value="">
<span class="error">
<div class="row">
<div class="twelve columns">
<label for="contact_name">Your Name *
<input type="text" id="contact_name" name="fields[name]" value="">
<span class="error">
<div class="row">
<div class="twelve columns">
<label for="contact_message">Message *
<textarea type="text" id="contact_message" name="fields[message]" value="" rows="10">
<span class="error">
<input type="text" name="hp" value="" style="display: none">
<input type="submit" class="button" value="Submit">
{{ close_form() }}
The email
, name
and message
fields are required.
You may notice the hp
input in the form code above. This implements the honeypot anti-spam solution.
Custom Contact Form Fields
You can add as many custom fields to any LemonStand contact form! Here's an example:
...
<label for="custom_field">Custom field</label>
<input type="text" id="custom_field" name="fields[My custom field]" value=""/>
<span class="error"/>
Custom fields can be required. To make a custom field required it should be added to the Required Fields list on the Contact Form settings page:

Email Templates
By default, the system:contact-message
email template is used for sending contact form notifications. It's possible to use another template or use multiple contact forms that each send notifications using different email templates.
The email template name can be supplied in a hidden field called template
:
...
<input type="hidden" name="template" value="system:custom-contact-form-template"/>
<input type="submit" class="button" value="Submit"/>
{{ close_form() }}
Subject lines
The subject line can be overridden as well, with the subject
hidden field:
...
<input type="hidden" name="subject" value="Custom subject"/>
<input type="submit" class="button" value="Submit"/>
{{ close_form() }}
Redirect and success messages
When the form is sent, the page refreshes and a confirmation success message is displayed. The redirection URL and the confirmation text can be set with the redirect
and successMessage
hidden fields:
...
<input type="hidden" name="redirect" value="/message-sent"/>
<input type="hidden" name="successMessage" value="Your message has been sent. Thank you!"/>
<input type="submit" class="button" value="Submit"/>
{{ close_form() }}
Email notification template
The system:contact-message
email template is installed by default, but you can set up more contact form email templates as well.
Inside this template, any contact form field defined as fields[name]
in the contact form is accessible by its name. The {{ customFields }}
variable outputs all the custom fields. Default email template with variables text:
<p>Hello!</p>
<p>A visitor {{ name }} ({{ email }}) has sent a message from the contact form:</p>
<blockquote>{{ message }}</blockquote>
{{ customFields|raw }}