Search »

Form Builder

Using the Smarty templating language

The Form Builder, like Form Tools, uses the Smarty templating language to provide more control over your generated forms. Smarty lets you add logic (if-else, etc.) clauses to your templates and resource files, output the content of variables (placeholders), manipulate data and much more.

Smarty is fairly easy to learn, and - compared to programming languages - more limited, which simplifies things. Currently Form Tools uses version 2 of Smarty, so if you decide to check out their documentation, make sure you're looking at the right version!

We won't attempt to teach Smarty here - there's far too much to cover and it would be redundant when there's some online documentation available by the original developers. However, a few things are worth bringing up.

Smarty Delimiters

Unlike the email templates, Export Manager and other places where Smarty is used, for the Form Builder, Smarty delimiters are the double curly brace: {{ and }}. Elsewhere, you use the single curly brace. This is because we found that with the Form Builder, you'd often be entering chunks of javascript and CSS - both of which use curly braces. So rather than having to force you to enter {literal} everywhere (which lets you enter single curly braces normally), we chose to use the double curly-brace delimiter.


To reference a variable (output its contents or access its values), you just use the following code:

The your_placeholder variable output the content of a placeholder; the your_resource variable outputs a full HTML <link>&; or <script> tag (depending on the resource type), to include that resource in your form page.

Smarty function calls

Smarty function calls look like variables, except they're missing the $ character. The Form Builder provides a number of built-in functions to handle the generation of particular template types (like and ).

Conditional Statements

Simple if-else statements will be the most likely thing you'll use in your Template Sets. They let you include code, show different content - whatever you want. Here's a couple of simple examples: