Skip to main content

Forms in entries

Introduction​

When a form belongs to the content rather than the template, such as a campaign landing page with its own sign-up form or an event with its own registration form, add the Formidable Form channel field. Editors choose a form on each entry, and the template prints it.

If every page of a template always shows the same form, you do not need the field. Put {exp:formidable:form form_handle="contact_us"} in the template instead.

  1. Create the field

    In Developer › Fields, create a field of type Formidable Form, for example named Form with the short name form. Optionally tick Forms to offer to limit the choice. With none ticked, every form on the site is offered, including forms created later. Add the field to a channel's field group.

  2. Choose a form on an entry

    The field lists the site's forms with their handle, field and submission counts, and a Closed badge for a form that has stopped accepting submissions. Click one to choose it. No form clears the choice. With more than six forms, a search box appears.

  3. Print it in the template

    templates/default_site/events.group/entry.html
    {exp:channel:entries channel="events" limit="1"}
    <h1>{title}</h1>
    {form}
    {/exp:channel:entries}

    With no form chosen, {form} prints nothing.

Passing parameters​

The field tag accepts the form tag's parameters and passes them on. The exception is form_id= and form_handle=, which are ignored, because the entry chose the form.

templates/default_site/events.group/entry.html
{form return="events/thanks/{url_title}" theme="bootstrap"}

Markup around the form​

Variable
{form:id}, {form:handle}, {form:name}The chosen form

As a pair, {form}…{/form} prints nothing when no form is chosen, and inside it {form_id}, {form_handle}, {form_name}, {form_closed} and the rendered {form} are available:

templates/default_site/events.group/entry.html
{form}
<section class="form-panel">
<h2>{form_name}</h2>
{if form_closed}<p class="note">Registration has closed.</p>{/if}
{form}
</section>
{/form}

To write the form's markup yourself, use the form tag with the chosen id. ExpressionEngine fills in {form:id} before the inner tag runs, which is its default order, so do not add parse="inward":

templates/default_site/events.group/entry.html
{exp:channel:entries channel="events" limit="1"}
{exp:formidable:form form_id="{form:id}"}
{fields}{field_template}{/fields}
{/exp:formidable:form}
{/exp:channel:entries}

Grid, Fluid, Bloqs and Pro Variables​

The field also works as a Grid column, inside Fluid, as a Bloqs atom, and as a Pro Variables variable, with the same picker and tags. A Grid column and a Bloqs atom have their own Forms to offer setting. In Bloqs, print the atom inside its bloq's tag pair like any other atom:

templates/default_site/pages.group/index.html
{exp:channel:entries channel="pages" limit="1"}
{page_bloqs}
{form_bloq}
<section class="form-panel">{form return="thanks"}</section>
{/form_bloq}
{/page_bloqs}
{/exp:channel:entries}

Good to know​

  • The form's id is stored, not its handle, so renaming a handle does not break entries.
  • Captured forms are not offered, because their markup lives in the template that captured them. Convert one to a regular form to offer it.
  • Avoid full-page caching on templates that show a form, as for any form: each render carries a single-use CSRF token.
  • A form deleted after it was chosen is reported when the entry is opened. The editor must choose another, or No form, before saving.