Aptuitiv Studio Documentation

Displaying the Form

You can display a form on a page one of two ways.

  1. Setup the form and optionally the form fields in the Forms app. On the page that you want the form to display on you would build the HTML for the form.  You would include the special apFormKey hidden form field so that the system knows how to handle the form.
  2. Create the form in the Forms app and create one or more Form Templates.  Then put the Form API tag on the page that you want the form to display on. (Recommended)

You can find the Form API tag and the apFormKey tag under the Form Details tab when viewing a form.

Building the form on the page

If you're going to build the HTML for the form on a page and not use Form Templates then you must include the special apFormKey hidden form field so that the system knows how to handle the form.

Example tag: <input type="hidden" name="apFormKey" value="contact-form" />

Note: if you're going to save the form submissions you need to build the form fields under the Forms app.  Only the fields that are setup for a form in the Forms app will be saved.

Using Form Templates

The recommended way to display forms is to use Form Templates. This method provides the most functionality and the best experience for the site visitor. 

Benefits include:

  • Automatic generation of the <form> tag to include the correct action, method and enctype attribute values.
  • The special apFormKey is included in the output from the {#form.tag.open} tag to display the <form> tag and the hidden form tag in one step.
  • Easy tags to use to output the apFormKey and apFormStub tags if necessary.
  • Easier ways to display form fields. If your form uses a consistent layout then you can simply loop through the form fields to output them in far fewer lines of code.
  • Easier ways to output checkboxes, radio buttons and select menus with all of the correct options selected if necessary.
  • The ability to customize how errors are displayed in the forms.
  • If there is a form error then any values that were already submitted will be automatically filled into the appropriate fields.

When using a Form Template you simply need to use the Form API tag to display the form on a page.

Example tag: {ap_api:form:getForm key="contact-form"} .

Place the API tag on the page where you want the form to show and when the page is displayed the form will automatically be built and displayed.

Advanced API Tags

You can customize the API tag that retrieves the form template by setting different API tag parameters.

This is useful if you want to display the form in multiple areas of the site but the form is displayed differently in each section.

You don't need to customize the API tag if you only want to show the form with the default form template.

Basic tag: {ap_api:form:getForm key="contact-form"}

API Tag Parameters

templateId

The numeric ID of the form template to use.
Example: templateId="3"

Example Tag

{ap_api:form:getForm key="contact-form" templateId="5"}

The above tag will display the form using the form template that has an ID of 5.