Forms List
The Forms List attribute is a select list that contains all forms created in the Forms app. Selecting a form from the Forms List attribute when creating content will output the API tag for that form.
Using the field in templates
The value from field in your templates will be an object. The output from the field will be the form API tag to load the form. There are two ways to output that value.
In the examples on the page we're going to assume that the field is called "Form" and it's template key is "form".
The first is to simply output the variable.
{{ form }}
The other way is similar to HTML objects and it's to use the tag value.
{{ form.tag }}
Setting API parameters
Because the field value is an object, you can set the Form API parameters before outputting the API tag. The allowed parameters are:
- template - the form template key
- field - Any options for the field.
See the Form API page for more information on the API parameters.
For example, to set the form template to be something different from the template assigned to the form you can do the following:
{% set form.template = 'form-template-key' %}
{{ form.tag }}
The field value would be an object where the keys are the field template keys and the values are an object containing the attributes to set. For example:
{% set form.field = {
fieldKey: {value: 'Field default value', class: 'myClass'}
} %}
You can set the field value as an array, or you can set it as a chained value like this:
{% set form.field.myField.value = 'Field value' %}
{% set form.field.myField.class = 'myClass' %}
{% set form.field.anotherField.value = 'Another value' %}
{{ form.tag }}