Token Field

The token field. This provides an implementation of the Bootstrap TokenField plugin on top of a text field to allow for autocomplete and typeahead tokens in a comma (or alternative separator) delimited string.

For full documentation on the options available for the Bootstrap Tokenfield plugin, see: http://sliptree.github.io/bootstrap-tokenfield

For full documentation on the options available for the Twitter Bloodhound Suggestion engine, see: https://github.com/twitter/typeahead.js/blob/master/doc/bloodhound.md

Properties

Title Token
Description Token field for entering list of tokens separated by delimiter
Field Type token
Base Field Type text

Schema

Property Type Default Description
allowOptionalEmpty Allows this non-required field to validate when the value is empty
autocomplete string Allows you to specify the autocomplete attribute for the underlying input control whether or not field should have autocomplete enabled.
data object Allows you to specify a key/value map of data attributes that will be added as DOM attribuets for the underlying input control. The data attributes will be added as data-{name}='{value}'.
disallowEmptySpaces boolean Whether to disallow the entry of empty spaces in the text
disallowOnlyEmptySpaces boolean Whether to disallow the entry of only empty spaces in the text
enum array List of specific values for this property
inputType string Allows for the override of the underlying HTML5 input type. If not specified, an assumed value is provided based on the kind of input control (i.e. 'text', 'date', 'email' and so forth)
maskString string Expression for the field mask. Field masking will be enabled if not empty.
placeholder string Field placeholder.
size number 40 Field size.
trim boolean Remove whitespace from the beginning and end of string
typeahead Provides configuration for the $.typeahead plugin if it is available. For full configuration options, see: https://github.com/twitter/typeahead.js

Options

Property Type Default Description
name string Field Name.
separator string , Separator used to split tokens.
sort function Defines an f(a,b) sort function for the array of enumerated values [{text, value}]. This is used to sort enum and optionLabels as well as results that come back from any data sources (for select and radio controls). By default the items are sorted alphabetically. Don't apply any sorting if false.
tokenfield object Settings to pass into the underlying bootstrap-tokenfield control

Example 1

Here is a token field that lets you pick character first names from the movie Back to the Future.

{% raw %} {% endraw %}

Example 2

Here is the same thing but using a display-only view.

{% raw %} {% endraw %}

Example 3

Here is a form with the token field taking in some of the values. This form uses Ajax to retrieve the autocomplete values from a remote source. Click the submit button to see the resulting JSON.

{% raw %} {% endraw %}