Available Variables

The following Twig functions are available to call in your Twig templates.

craft.formie.forms(query) #

See Form Queries

{% set form = craft.formie.forms({ handle: 'contactForm' }).one() %}

craft.formie.submissions(query) #

See Submission Queries

{% set submissions = craft.formie.submissions({ formId: 123, limit: 10 }).all() %}

craft.formie.renderForm(form, options = {}) #

Renders the entire form, taking into account custom Form Templates. The form parameter can be a Form object, or the handle of a form. For details on the options you can pass into the options parameter, see Rendering Options.

{{ craft.formie.renderForm('contactForm') }}

craft.formie.renderPage(form, page) #

Renders a single page, taking into account custom Form Templates. This will also include captchas (if enabled) and submit button(s).

{% set form = craft.formie.forms({ handle: 'contactForm' }).one() %}

{% for page in form.getPages() %}
    {{ craft.formie.renderPage(form, page) }}
{% endif %}

craft.formie.renderField(form, field) #

Renders a single field, taking into account custom Form Templates.

{% set form = craft.formie.forms({ handle: 'contactForm' }).one() %}

{% for field in form.getFields() %}
    {{ craft.formie.renderField(form, field) }}
{% endif %}

craft.formie.registerAssets(form, options = {}) #

Used to specifically register the CSS and JS for a form. Takes the same arguments as craft.formie.renderForm. This is particular useful for Cached Forms.

{% do craft.formie.registerAssets('contactForm') %}

craft.formie.getFieldOptions(field) #

Returns a field's render options from the main options array.

craft.formie.getLabelPosition(field) #

Returns the label position for a field.

{% set labelPosition = craft.formie.getLabelPosition(field, form) %}

{% if labelPosition.shouldDisplay('above') %}

craft.formie.getInstructionsPosition(field) #

Returns the instructions position for a field.

{% set instructionsPosition = craft.formie.getInstructionsPosition(field, form) %}

{% if instructionsPosition.shouldDisplay('below') %}

craft.formie.getParsedValue(value, submission) #

For parsing a variable-string against a submission. For example, you might have a field with a handle emailAddress, and you could use the string {emailAddress} and a supplied submission to swap the template tag with the content from a submission.

{% set toEmail = craft.formie.getParsedValue('Send me an email to {emailAddress}', submission) %}

craft.formie.setCurrentSubmission(form, submission) #

Sets the current submission for a particular form. This is mostly used for multi-page forms.

Get started with Formie

Available for Craft 3. Get it from the plugin store.