Repository navigation
Checking a forms site in a template
Written against v0.6.1.
A form assigned to some sites renders nothing on the others, but the heading or introduction around it still renders. The form:assigned tag tells a template whether the form renders on the page's site, so it can hide those, or show something else in their place.
Use the tag as a condition, or as a pair that renders its contents only where the form does:
{{ if {form:assigned in="contact"} }}
<h2>Contact us</h2>
{{ /if }}
{{ form:assigned in="contact" }}
<p>We reply within two working days.</p>
{{ /form:assigned }}
{{ unless {form:assigned in="contact"} }}
<p>Write to us at info@example.com.</p>
{{ /unless }}
{{ form:create in="contact" }}
...
{{ /form:create }}With the form assigned to the English site only, the English page shows the heading, the reply time and the form; the Spanish page shows only the line pointing to the email address.
Fetch the tag for a condition, or use the pair as a component:
@if (Statamic::tag('form:assigned')->params(['in' => 'contact'])->fetch())
<h2>Contact us</h2>
@endif
<s:form:assigned in="contact">
<p>We reply within two working days.</p>
</s:form:assigned>
@unless (Statamic::tag('form:assigned')->params(['in' => 'contact'])->fetch())
<p>Write to us at info@example.com.</p>
@endunlessform:assigned never aborts a page or logs anything. To answer with the site's 404 page wherever the form is not assigned, set not_assigned instead; see Showing a form on some sites only.
- Form assigned tag: every result, and the ways to name the form.
-
Configuration: what the
{{ form }}tags do on a site the form is not assigned to.
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