Form Studio forms
Every Basin form has an endpoint, and you can write your own markup for it. Form Studio is the other option: you design the form in Basin, and Basin builds the markup for you. It’s the same form either way, with the same submissions, notifications and settings.
To show a form’s Form Studio version on your site, the plugin needs its embed code.
Add the embed code
Section titled “Add the embed code”Basin doesn’t share Form Studio embed codes through its API, so each one is added once, by hand:
- In Form Studio, open the form’s Publish tab and copy the one-line
<script>embed. The script URL or the hosted form URL also work. - In Craft, go to Basin → Forms, open the form, and paste it under Form Studio embed.
- Click Save embed code. The plugin checks it with Basin before saving.
This needs the Set up forms on this site permission. Embed codes are saved in the database, so they can be added on your live site.
Show the form
Section titled “Show the form”{{ craft.basin.render('demo00quotes') }}craft.basin.render() outputs Basin’s embed script, which shows the form where it’s placed. It takes a form’s Basin ID, a form, or a Basin Form field’s value:
{{ craft.basin.render(entry.contactForm) }}There’s no need to check the form exists first. If it doesn’t, render() outputs nothing for visitors (see below).
The form runs inside Basin’s embed, so Basin handles its CAPTCHA, submission and thank-you message or redirect. The plugin’s spam protection and reCAPTCHA settings only apply to your own markup. Set these in Basin instead:
- CAPTCHA: on Form Studio’s Publish tab (reCAPTCHA v3 or Cloudflare Turnstile).
- Thank-you message or redirect: under Redirects in the form’s Settings → General. By default a redirect only changes the embed; to send the whole page there, turn on Redirect Parent Page on Form Studio’s Publish tab.
Add page details to submissions
Section titled “Add page details to submissions”Pass hiddenFields to add values from the page to every submission, such as which entry the form was on:
{{ craft.basin.render(entry.contactForm, { hiddenFields: { page: entry.title, entryId: entry.id, },}) }}They’re sent to the form with Basin’s addHiddenFields message, and appear in each submission alongside the form’s own fields. Values are sent as text. Don’t use action as a name: Basin’s message uses it.
Hidden fields are visible to anyone who looks at the page’s source, so don’t include anything private.
If the form can’t be shown
Section titled “If the form can’t be shown”craft.basin.render() never breaks your page. When a form can’t be shown:
- visitors see nothing (just an HTML comment in the source);
- in
devModeand in Live Preview, a notice appears in the form’s place, explaining why; - it’s recorded in the error log, with the page it was used on.
That covers an empty field, a form that’s no longer in your Basin project, and a form with no embed code saved.
To show your own markup when a form has no embed code, check form.isStudioForm:
{% set form = entry.contactForm %}{% if form and form.isStudioForm %} {{ craft.basin.render(form) }}{% elseif form %} <form action="{{ form.action }}" method="post">…</form>{% endif %}If the embed code stops working
Section titled “If the embed code stops working”If a form’s Form Studio version is deleted or regenerated, its saved embed code stops working. The form’s page in the Control Panel and the error log tell you, and you can paste the new code.
form.render()
Section titled “form.render()”form.render() does the same as craft.basin.render(form), and takes the same options. Use it when you already have the form, inside {% if form %}.