Templating
FAQs
Introduction
Templating is a fancy way of having Wufoo dynamically replace a shortcut phrase with data filled in from the user on your forms. The easiest way to explain the concept is with an example. Let’s start with a simple template:
Hello from {entry:Field1} {entry:Field2}.
The above template, when displayed back to your users, will replace {entry:FieldX} with the data typed in from the form associated with those fields:
Hello from Ryan Campbell.
The templating system replaces the bracketed phrases, which have data containing IDs referencing the fields in your form, with the data that the user typed in from that entry. This is really useful for situations where you want to use the data from the user to create a customized response. Most users on Wufoo utilize templating for the confirmation page and confirmation emails.
Formatting Guide
Now that we know how templating works, we need to find out how to construct our own. Templating consists of two parts:
- A template
- A parameter
Based on that, we can break down the original example:
- Template: {entry:}
- Parameter: Field1
The template tells Wufoo to use entry data (that’s data the user typed into the form), and the parameter tells Wufoo which field to grab the data from. The only tricky part here is to find out what to put in the parameter. How can you distinguish between Field1, Field2, or FieldX. This is where the API comes in.
1) Log in to your Wufoo account.
2) Click Code button under the form’s name in the Form Manager.
3) Click on the API Information button in the upper right hand corner.
Once you are on the API information page, you will see a list of all of your fields and they will have a unique number in front of them. The number that you see is the ID of the field. So, if you want to construct a template, and the field has an ID of 3 next to it, your template would look like this:
{entry:Field3}
Fields Accessible by Templates
We have seen that all fields in our form can be accessed by a template, but can anything else? Currently, the following are supported:
Form Templates
- {form:FormId} - The unique ID of the Form.
- {form:Name} - The form’s name as defined in your Form Settings.
- {form:Description} - The form’s description as defined in your Form Settings.
Entry Info
- {entry:EntryId} - The unique ID of the entry.
- {entry:TransactionId} - The unique ID of the payment transaction. This can only be used on forms integrated with Authorize.net or PayPal Payments Pro.
- {entry:DateCreated} - The date/time that the entry was submitted.
- {entry:PurchaseTotal} - For payment enabled forms, this will be a numeric value corresponding to the total amount paid.
- {entry:IP} - IP address of the computer that submitted the entry.
We plan on adding more data to this as our templating system grows.
Altering Output
In certain cases, it may be desirable to change the way a template is displayed to the screen. For example, a date could be changed from 20101213 to 12/13/2010. To use an output filter, apply the | character directly after the parameter. For example:
{entry:Field5|date_format:"m/d/Y"}
The above statement would select the value for Field5, apply the date_format filter, and use the m/d/Y format. A list of all available filters and formats is below:
date_format - This filter accepts any of these formats. For example, “D” would give you Tue, and “F Y H:i:s” would output December 2010 1:20:32.
Currently, Wufoo will only support altering outputs for the Date/Time formats.
Where can I use templates?
Templates can be used in the Message Subject and Name or Subject fields for Notification Settings, in the receipt message for Send Confirmation Email to User, and in the Text Confirmation for Forms.
We also have simple templating for the Redirect URL. The {entry:EntryId} command is valid, so that you can append the entry Id to the URL that you wish to redirect to. You may also use any of the other template commands listed above, but this functionality is unsupported because we don’t provide a way to URL encode the URL. This means if you have an unacceptable (non-ascii or control character like a slash) in your resolved template, the URL will break.
How do I find my API information?
To locate your API Information and coinciding field API IDs necessary for successfully templating input, follow these steps:
- Click on the Code button in the management options for your form
- Click on the API Information button in the top right corner of the page
- You'll be on the API Information screen now where you'll be able to locate the API ID's