Tutorial: Add options to a template

This tutorial assumes that you already have a form template that you want to add options to.  First, options are added at the top of the template, just below ‘Template Type’.  You should examine the default template (fm-form-default.php) to get an idea of what is involved in specifying an option.  The very first line in specifying an option looks like the following:

option: $varName, (type)

Here, $varName is the php variable you want the option’s value to be loaded into, and ‘type’ is either ‘text’, ‘checkbox’, or ‘select’.  The next part of the specification is the label:

label: (Option label goes here)

This will appear next to the option in the form editor.  You can also add a description:

description: (short description goes here)

The next thing to specify will be the default value.  If your option is of ‘text’ type, then this can be any text value.  If the item is a ‘checkbox’, then you only need to specify something if you want the checkbox to be checked by default; in this case, you would specify the default value to be ‘checked’.  Here is an example of a fully formed ‘text’ option:

option: $textVar, text
label: Enter some text
description: This is where you would enter some text
default: Hello there

And a fully formed ‘checkbox’ option, that is checked by default:

option: $checkboxVar, checkbox
label: Do the thing?
description: Check the box if you want to do the thing
default: checked

If your option is a ‘select’ type, then you must specify the options to choose from, and the values associated with those options.  For example, you might have options like “This is the first option” and “This is the second option”, but you only want to store the values “option1” and “option2” in your variable.  The following shows you how to specify the options for a ‘select’ type:

options: 'option1' => "This is the first option", 'option2' => "This is the second option"

Below is a fully formed 'select' type, where the second option is set as the default:

option: $selectVar, select
label: Choose an option
description: Seriously, just pick something
options: 'option1' => "This is the first option", 'option2' => "This is the second option"
default: option2