Use data from Mautic form submissions in your Twig templates.
{{ formresult }}
: Contains the data from the single, most recent form submission by the contact for the form that triggered the action.
{{ formresults }}
: Contains a list (array) of all form submissions made by the contact for the triggering form.
getFormResults(formId, contactId, limit, page, orderBy, orderDirection)
:formId
(required): The ID of the form.contactId
(optional): The contact’s ID. If omitted or null
, fetches results for all contacts.limit
(optional): Max number of results per page.page
(optional): Page number (default: 1).orderBy
(optional): Field to sort by (default: 's.date_submitted'
).orderDirection
(optional): 'ASC'
or 'DESC'
(default: 'DESC'
).getFormResultsCount(formId, contactId)
:formId
: (Required) The integer ID of the Mautic Form you want to query.contactId
: (Optional) The integer ID of the Mautic Contact. If provided, counts submissions for that specific contact only. If omitted or null
, counts submissions for the form across all contacts.getFormResultsCount
)getFormResultsCount
function to set a registration cap for a form. For example, if you want to stop accepting new registrations after a certain number of people have registered, you can use Twig logic to display a message instead of the form.
getFormResults
)getFormResults
Twig function to fetch submissions for any form by its ID, with optional filters and pagination.
Each submission
in the results contains all the form field values, accessible by their alias (the unique name you gave the field). For example, if your form has fields with aliases firstname
, email
, and company
, you can access them as submission.firstname
, submission.email
, and submission.company
.submission.dateSubmitted
and submission.leadId
.
Example: Display Recent Form Submissions in a Table
Let’s say you want to show the last 3 times a contact filled out Form 12. Here’s how:
formresult
)formresult
token. You access the submitted values using the form field’s alias (the unique name you gave the field).
formresults
)formresults
list. Each item in the list (result
in the example below) works like the formresult
token.