Repository navigation
Your first multisite form
Written against v0.6.1.
By the end of this page you will have a contact form that shows on one site, then on two, with each site's submissions stored apart and each site's email going to its own recipient.
It assumes the add-on is installed (see Installation (README)) in a multisite install with two sites: English (en, at /) and Spanish (es, at /es/). Use your own site handles where these appear.
In the Control Panel, create a form named Contact (handle contact) with Name, Email and Message fields, and an email to info@example.com. Statamic's forms documentation covers this step; nothing about it is specific to the add-on.
The form file, resources/forms/contact.yaml, now holds the form's title and email, and no sites.
Put the form on a template that both sites render, as you would on a single site:
{{ form:create in="contact" }}
{{ fields }}
<label>{{ display }} {{ field }}</label>
{{ /fields }}
<button type="submit">Send</button>
{{ /form:create }}Visit the page on each site. The form shows on both, because a form with no sites belongs to every site.
Open the form's settings. In the Sites section, choose English in the Sites field, and save.
The form file now lists the site:
sites:
- enVisit the page again:
- On the English site, the form shows.
- On the Spanish site, the page renders without the form, and the log records why:
local.WARNING: Multisite Forms rendered nothing for a form not assigned to the page's site. {"form":"contact","site":"es"}
Note: to answer with the site's 404 page instead, set not_assigned to 404; see Configuration.
Fill in the form on the English page and send it. The submission is stored, and its file under storage/forms/contact/ records the site it came from:
_site: enA submit to the form from the Spanish site answers 404, even from a request made by hand, since the form is not assigned there.
Open the form's settings again:
- In the Sites field, add Spanish.
- Under Site overrides, choose Add site override, pick Spanish, set the title to
Contacto, and add an email toinfo-es@example.com. - Save.
The form file now carries the override row:
sites:
- en
- es
site_overrides:
-
site: es
title: Contacto
email:
-
to: info-es@example.com
subject: 'Consulta del sitio'The form now shows on both pages. Send one submission from each:
- The Spanish one is emailed to
info-es@example.comand stored with_site: es. - The English one is emailed to
info@example.comand stored with_site: en.
A site's row replaces only what it sets; everything else comes from the form. See Per-site title, email and store for every setting a row can hold.
Open the form's submissions in the Control Panel. A super user sees all three, and a Site filter narrows the listing, and an export, to one site. An editor who can access only the Spanish site sees only the Spanish submission. Control Panel access describes who sees what.
- Form assigned tag: hide a heading or introduction on a site where the form does not show.
- Attribute command: give submissions saved before the add-on a site.
- Home: the guides by role, and the rest of the reference.
Home | README | Repository
Written against v0.6.1. These pages are edited in docs/wiki/ through a pull request; an edit made in the wiki is overwritten by the next publish.
Guides for site builders
- Showing a form on some sites only
- Giving each site its own title, email and store
- Checking a form's site in a template
Guides for administrators
Guides for developers
Troubleshooting
Reference
- Configuration
- Per-site title, email and store
- Control Panel access
- Attribute command
- API site filter
- Form assigned tag
- Site form view
- README
Project