form

This component outputs data relating to a specific Form.

{% component type: "form", alias: "<form_alias>" %}

Parameters and Options

Parameter Values Required Description
type form

This is the name of the entity that needs to be used for the component retrieving function.

alias <alias_name> The alias name of the module.
collectionVariable <yourLiquidVariableName>
Assigns the data to a Liquid collection enabling further access to the data on the Page or Template using Liquid.
If using this parameter, the form will not render its layout.

Your collectionVariable value must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

type <number>
If the form is collecting payment as type 'Generic', this parameter can be used to pass the price value to the form.
type <ID>
If the form is subscribing a user to an Event and/or is collecting payment as type 'SingleItem' for an Event subscription, this parameter is used to pass the Event ID to the form to assign the required Event and any price values for payment.
<customParameter> <your custom value>
You can add your own additional parameters (name/value pairs) to the Component tag. These will be passed to the Components Layout (and the collectionVariable if used) for use via Liquid.

Your <customParameter> name must only contain English letters, numbers or underscores. Spaces or special characters are not supported.

You can use HTML as the value here, just be sure to change any double quotes in your HTML to single quotes.

Liquid Output

The below form example has 4 system fields and 2 custom fields and represents the typical data structure you will see from this Component.

{
  "Name": "Sample Form",
  "Alias": "sample_form",
  "Fields": [
  {
    "Id": 162,
    "FormId": 10,
    "Name": "Email",
    "Alias": "Email",
    "CreatedDateTime": "2018-11-07T10:15:01.553",
    "UpdatedDateTime": "2018-11-07T10:15:01.553",
    "Type": 7,
    "IsMandatory": true,
    "IsSystem": true,
    "Options": [],
    "Order": 0
  },
  {
    "Id": 163,
    "FormId": 10,
    "Name": "First Name",
    "Alias": "FirstName",
    "CreatedDateTime": "2018-11-07T10:15:01.587",
    "UpdatedDateTime": "2018-11-07T10:15:01.587",
    "Type": 7,
    "IsMandatory": true,
    "IsSystem": true,
    "Options": [],
    "Order": 1
  },
  {
    "Id": 164,
    "FormId": 10,
    "Name": "Last Name",
    "Alias": "LastName",
    "CreatedDateTime": "2018-11-07T10:15:01.623",
    "UpdatedDateTime": "2018-11-07T10:15:01.623",
    "Type": 7,
    "IsMandatory": true,
    "IsSystem": true,
    "Options": [],
    "Order": 2
  },
  {
    "Id": 165,
    "FormId": 10,
    "Name": "Phone",
    "Alias": "Phone",
    "CreatedDateTime": "2018-11-07T10:15:01.657",
    "UpdatedDateTime": "2018-11-07T10:15:01.657",
    "Type": 7,
    "IsMandatory": false,
    "IsSystem": true,
    "Options": [],
    "Order": 3
  },
  {
    "Id": 166,
    "FormId": 10,
    "Name": "Enquiry",
    "Alias": "Enquiry",
    "CreatedDateTime": "2018-11-07T10:15:01.697",
    "UpdatedDateTime": "2018-11-07T10:15:01.697",
    "Type": 6,
    "IsMandatory": true,
    "IsSystem": false,
    "Options": [],
    "Order": 4
  },
  {
    "Id": 167,
    "FormId": 10,
    "Name": "reCAPTCHA v2",
    "Alias": "ReCAPTCHAV2",
    "CreatedDateTime": "2018-11-07T10:15:01.73",
    "UpdatedDateTime": "2018-11-07T10:15:01.73",
    "Type": 9,
    "IsMandatory": true,
    "IsSystem": false,
    "Options": [],
    "Order": 5
  }
],
  "Parent": {
  "Count": 48,
  "Items": [
    {
      "Key": "Id",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "Url",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ParentId",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "LastUpdatedDate",
      "Value": {
        "Type": 7
      }
    },
    {
      "Key": "Name",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "UrlSlug",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "Enabled",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "ReleaseDate",
      "Value": {
        "Type": 7
      }
    },
    {
      "Key": "ExpiryDate",
      "Value": {
        "Type": 7
      }
    },
    {
      "Key": "Weighting",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "Description",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ItemTags",
      "Value": {
        "Type": 1
      }
    },
    {
      "Key": "Author_Name",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "Author_Url",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "Author",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "SEOTitle",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "MetaTitle",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "MetaDescription",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ShowPageForSearchEngine",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "CanonicalLink",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "EnableAMP",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "AMPContent",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "CodeEditor",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "ExternalId",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "SocialMetaTags",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "OpenGraphProperties",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "DisableForSiteSearch",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "SeoPriority",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "CreatedByMemberId",
      "Value": {
        "Type": 4,
        "IsIntegral": false
      }
    },
    {
      "Key": "ItemCategories",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "ItemCategoryIdList",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "SKUCode",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "SiteSearchKeywords",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "Active",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "IgnoreUpdates",
      "Value": {
        "Type": 2
      }
    },
    {
      "Key": "UpdateNotes",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ExternalResources",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "AdditionalRelatedArticle_Name",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle_Url",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "AdditionalRelatedArticle2_Name",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle2_Url",
      "Value": {
        "Type": 0
      }
    },
    {
      "Key": "AdditionalRelatedArticle2",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "Authors",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ParentName",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "ParentUrl",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "TemplateName",
      "Value": {
        "Encode": true,
        "Type": 6
      }
    },
    {
      "Key": "IsHome",
      "Value": {
        "Type": 2
      }
    }
  ]
},
  "Params": {
  "alias": "sample_form",
  "collectionVariable": "data"
},
  "PaymentAmount": 0.0,
  "ModuleItemId": 0,
  "ModuleName": "",
  "FormType": "Generic"
}

Field Type Codes

From the data output you can identify the type of field created in the admin via it's Type property.
The various types are listed below:

  • DateTime - 1
  • CheckboxList & MailingLists - 2
  • DropdownList - 3
  • ListboxList - 4
  • RadioList - 5
  • Multiline - 6
  • String - 7
  • Boolean - 8
  • ReCAPTCHAV2 & ReCAPTCHAV3 - 9
  • Upload - 10
  • Password - 11
  • AcceptPayment - 12
  • AcceptEventSubscription - 13

System fields Email, FirstName, LastName, Phone, Site, Address, City, State, ZipCode, Country, Status, Secure Zone Expiry Date, Secure Zone Expiry Duration all use type 7, and field Notes uses type 6.

Accessing the Data

As an alternative, you can instead output the form data directly on the Page or Template via a Liquid Collection if collectionVariable was added to the Component tag.

An example using collectionVariable with value "formData" is as follows:

{% component type: "form", alias: "sample_form", collectionVariable: "formData" %}

Looping through the collection to render all the field names:

{% for f in formData.fields %}
    {{f['Name']}}<br>
{% endfor %}

Accessing a specific item within the collection. In this case the third fields name (zero based index):

{{formData.fields[2]['Name']}}


Related Articles

  • System Pages
    System Pages, under 'Settings', is where you’ll find all those pages required by certain system...
  • Form Submissions
  • System Emails
    System emails are emails that are sent when a particular action is carried out on the website and/or via the admin.
  • {{ formSubmissionData }} object
    This liquid object will output the submission details of a Form.
  • {{ workflow }} object
    This liquid object will output the Workflow details of a submitted Form. You can use...
  • {{ order }} object
    This liquid object will output the order details of a submitted payment. {% capture data...
  • Forms
    {% increment taskCnt %} Forms are an essential part of collecting user information on your...
  • Secure Zones
    Secure Zones provide a way of creating restricted content on your website that only registered Secure Zone Members are able to access after successfully logging in.
  • ReCaptcha Styling
    Treepl CMS supports Google reCAPTCHA v2 and v3 implementations. Below are some additional options you...

External Resources


Please let us know if you have any other contributions or know of any helpful resources you'd like to see added here.


Questions?

We are always happy to help with any questions you may have.
Send us a message at support@treepl.co and we will consult you as soon as possible.