Form Template Tags

Form Tags

Tag Description
{#form.errors} Type: Array
Description: An array of validation errors for the form if there are any. 
{#form.fields} Type: Array
Description: An array of form fields that have been created for the form if there are any.
{#form.honeyPot} Type: String
Description: The honeypot field HTML. A honeypot field is a technique to help prevent form spam.
{#form.key} Type: String
Description: The special hidden form field that tells the system what the form is and how to handle it.
If the {#form.tag.open} tag is used this value is included in that tag.
Example: <input type="hidden" name="apFormKey" value="formKey" />
{#form.method} Type: String
Description: The value for the method attribute of the <form> tag.
{#form.stub} Type: String
Description: The special hidden form field that tells the system that this form is a Form Stub.
Example: <input type="hidden" name="apFormStub" value="1" />
{#form.tag.action} Type: String
Description: The value for the action attribute of the <form> tag. This will automatically be set to be the URL of the page that the form is displayed on.
{#form.tag.class} Type: String
Description: The value for the class attribute of the <form> tag.
{#form.tag.close} Type: String
Description: The closing </form> tag.
{#form.tag.enctype} Type: String
Description: The value for the enctype attribute of the <form> tag.
The default value is application/x-www-form-urlencoded.
If there is one or more file upload fields created for the form then the value will be multipart/form-data to support uploading files.
{#form.tag.id} Type: String
Description: The value for the id attribute of the <form> tag.
{#form.tag.method} Type: String
Description: The value for the method attribute of the <form> tag. Defaults to "post"
{#form.tag.name} Type: String
Description: The value for the name attribute of the <form> tag.
{#form.tag.open} Type: String
Description: The opening <form> tag with the appropriate attributes. Also includes the special apFormKey hidden field.
Example: <form action="/url" method="post"><input type="hidden" name="apFormKey" value="formKey" />
{#form.tag.style} Type: String
Description: The value for the style attribute of the <form> tag.
{#form.tag.target} Type: String
Description: The value for the target attribute of the <form> tag.
{#form.tag.title} Type: String
Description: The value for the title attribute of the <form> tag.

Field Tags

Below are the tags to use if you're going to loop through the form fields.

You can loop through the form fields with the following tags:

{loop items="#form.fields" value="field"}
{/loop}

Tag Description
{#field.class} Type: String
Description: The value for the class attribute of the form field tag.
Note that for Text and Textarea fields if a size of Small, Medium or Large is chosen then a class of small, medium or large respectively will be set for the field.
A field can have more than one class.
{#field.cols} Type: String
Description: The value for the cols attribute of the <textarea> tag.
This value is only applicable if the field is a Textarea.
{#field.description} Type: String
Description: The descriptive text for the form field.
{#field.error} Type: String
Description: An error for the field if there was one.
{#field.id} Type: String
Description: The value for the id attribute of the form field tag.
{#field.isRequired} Type: Boolean
Description: Whether or not the field is required. 
{#field.label} Type: String
Description: The label text for the field.
This is NOT the <label> tag.
{#field.name} Type: String
Description: The name of the field.
{#field.options} Type: Array
Description: An array of option values for the field.
This only applies if the field is a Checkbox, Multiple Checkbox, Radio Button or Select Menu.
{#field.rows} Type: String
Description: The value for the cols attribute of the <textarea> tag.
This value is only applicable if the field is a Textarea.
{#field.size} Type: String
Description: The size of the field.
Possible values are "small", "medium", "large", "custom".
This value is only applicable if the field is a Text Box or Textarea.
{#field.sizeCustom} Type: String
Description: The value for the size attribute of the <input> tag.
This value is only applicable if the field is a Text Box and the Field Size is "Custom Size".
{#field.tag} Type: String
Description: The full tag for the form field.
{#field.type} Type: String
Description: The type of form field that the field is.
Available types:
button
checkbox
mutiCheckbox
file
radio
reset
select
submit
text
textarea
{#field.value} Type: String or Array
Description: The submitted value for the form field. This would only apply if there were errors with the form or if a Form Stub was used to feed into a full form.
If the field is Multiple Checkboxes then this value will be an array.

Field Options

Below is the tags for the {#field.options} array.  These tags would only be used if the field is a Checkbox, Multiple Checkbox, Radio Button or Select Menu.

You can loop through the field options with the following tags:

{loop items="#field.options" value="option"}
{/loop}

Tag Description
{#option.isDefault} Type: Boolean
Description: Whether or not the option value is the default value.
{#option.isSelected} Type: Boolean
Description: Whether or not the option value should be selected.
This would only be true for one of three cases:
  1. if the option value is either a default value
  2. the form was submitted and there were errors and this option's value for this field was submitted
  3. the form was submitted and it was a stub form and this option's value for this field was submitted
{#option.label} Type: String
Description: The label text for the option value.
{#option.value} Type: String
Description: The value for the option.

Working with Individual Form Fields

If you're not going to loop through the form fields and need to access individual fields you can easily do so with the following tag:

{#form.fields.fieldName}

"fieldName" would be the name of the form field.  Note, that if your field name contains any spaces, dashes or underscore characters those characters are removed.  The name is in camelCase format.  On the right side of the Add/Edit Template page under the "This Form's Fields" section you will see a list of all available field names.

Form Error Tags

If the form is submitted and there are validation errors then the {#form.errors} tag will be populated with the errors that occurred.

You can loop through the form errors with the following tags:

{loop items="#form.errors" value="error"}
{/loop}

Tag Description
{#error.fieldName} Type: String
Description: The name of the form field that the error was for. 
{#error.message} Type: String
Description: The error message.