Twig
craft.basin.form(id)
Section titled “craft.basin.form(id)”Returns the form with that Basin ID, or null if it isn’t in the linked project. Check the result before writing your own markup:
{% set form = craft.basin.form('demo0contact') %}{% if form %}…{% endif %}craft.basin.render(form, options)
Section titled “craft.basin.render(form, options)”Outputs a form’s Form Studio embed. form is a Basin ID, a form, or a Basin Form field’s value. No {% if %} is needed: an empty field outputs nothing, and a form that can’t be shown outputs nothing for visitors and is recorded in the error log.
{{ craft.basin.render('demo00quotes') }}{{ craft.basin.render(entry.contactForm, { hiddenFields: { page: entry.title } }) }}| Option | |
|---|---|
hiddenFields |
Values added to each submission from this page. See Add page details to submissions. |
craft.basin.forms()
Section titled “craft.basin.forms()”Returns every form in the linked project, sorted by name. Returns an empty array if Basin can’t be reached and there’s no saved copy of your forms.
A form from craft.basin.form(), craft.basin.forms() or a Basin Form field has these properties and methods:
| Returns | |
|---|---|
form.uuid |
The Basin ID, e.g. demo0contact. |
form.name |
The form’s name in Basin. |
form.action |
The endpoint URL to post to, https://usebasin.com/f/{id}. |
form.useAjax |
Whether Basin’s Enable AJAX setting is on, so the form always responds with JSON, even to a plain form post. Requests sent with Accept: application/json get JSON either way. |
form.redirectUrl |
Where Basin sends visitors after submitting, or null for Basin’s thank-you page. |
form.timezone |
The form’s timezone in Basin. |
form.isStudioForm |
Whether a Form Studio embed code is saved, so craft.basin.render() can show it. |
form.studioScriptUrl |
The Form Studio embed script, or null. |
form.honeypotField |
The honeypot field’s name, if the form has a custom one. |
form.captcha |
recaptcha, hcaptcha, turnstile, or null. |
form.render(options) |
The same as craft.basin.render(form, options). |
form.honeypot(attributes) |
The hidden honeypot input. |
form.captcha(attributes) |
A placeholder the CAPTCHA is rendered into. Pass { version: 'v2' } or { version: 'v3' } to choose a reCAPTCHA version. |
form.spamProtection() |
The honeypot and CAPTCHA together. |
form.cpUrl |
The form’s page in the Control Panel. |
The helpers output nothing when a form doesn’t need them, and are already marked safe, so there’s no need for |raw.
HTML attributes
Section titled “HTML attributes”| Attribute | On | Effect |
|---|---|---|
data-basin-protect="false" |
<form> |
The automatic spam protection leaves this form alone. |
data-basin-recaptcha="v2" |
<form> |
Use reCAPTCHA v2 (or v3) for this form on this page. |