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 or Custom Rendering.

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

craft.formie.renderFormCss(form) #

Allows specific placement of a form's CSS on the page. Takes the same arguments as craft.formie.renderForm

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

<div class="form-wrap">
    {{ craft.formie.renderForm('contactForm') }}
</div>

craft.formie.renderFormJs(form) #

Allows specific placement of a form's JS on the page. Takes the same arguments as craft.formie.renderForm

<div class="form-wrap">
    {{ craft.formie.renderForm('contactForm') }}
</div>

{{ craft.formie.renderFormJs('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') %}
    <label>...</label>
    ...

craft.formie.getLabelPosition(field) #

Returns the label position for a field.

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

{% if labelPosition.shouldDisplay('above') %}
    <label>...</label>
    ...

craft.formie.getInstructionsPosition(field) #

Returns the instructions position for a field.

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

{% if instructionsPosition.shouldDisplay('below') %}
    <small>...</small>
    ...

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.

craft.formie.populateFormValues(handle, values) #

Populates the defaultValue of a field for a form. Note that this should be done before rendering the form. See Populating Forms.

{# Sets the field with handle `text` to "Some Value" for the form with a handle `contactForm` #}
{% do craft.formie.populateFormValues('contactForm', { text: "Some Value" }) %}

{# or use a `form` object #}
{% set form = craft.formie.forms({ handle: 'contactForm' }).one() %}
{% do craft.formie.populateFormValues(form, { text: "Some Value" }) %}

{# Must be done before the `renderForm()` #}
{{ craft.formie.renderForm('contactForm') }}

Get started with Formie

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