The use of templates facilitates the filling of forms by providing pre-formatted fields, and also helps to maintain the consistency of entries containing the same type of information.
A template is an entry like any other contained in a special container group of type “Templates”. There can be only one template group activated for a database but a template group can contain as many templates as desired.
Warning: Do not create standard entries in the templates group, because KeePassDX will try to interpret them for creating new entries in other groups. The creation of standard entries that contain your personal information must be done in other groups that you have created in your database.
Activation
The activation of templates is very simple, just open your database and activate the setting Setting -> Database settings -> Templates usage
. If you did not have any template group present in the root of your database, a new group containing default templates will be created. If you had a template group at the root, it will be reused for template generation.
The setting Setting -> Database settings -> Template group
allows you to select the group that contains the templates, you can switch with the one you want whenever you want.
Usage
When a template group is activated in the settings, a selection list will be available in the entry creation screen. This list is dynamic and the fields of your entry will be automatically modified according to the selected template. If filled fields from the old template are not present in the new selected template, they are automatically created as additional fields at the end of the form for this entry. It is possible to add new custom fields or attachments for the entry regardless of the currently active template.
Note : Templates reuse the basic fields of the KeePass format and add custom fields for the other template fields. If you use other KeePass clients that do not support templates, all your fields will still be visible.
Creation
As templates are entries like any other, it is possible to create, modify or delete templates, but a specific format must be respected.
Pseudo language
A pseudo language has been specially created to facilitate the creation of templates from an entry. This pseudo language is compatible with other template formats contained in KeePass plugins and other applications to be compatible everywhere, but is much easier to use.
Note : the use of this pseudo language solves a lot of syntax problems, information redundancy and allows a future evolution of the templates features (e.g. regex). However, to keep compatibility with other applications, the current storage format is translated in KPEntryTemplates language, which is a not very scalable, deprecated and will be replaced in the next updates of the KeePass format (discussion thread).
Format
- To create a new template, create an entry in the templates group. Unlike a regular entry, no fields are visible for this entry.
- The creation of a new field is done by creating a custom field, press the “3 lines” button.
- Give your field a name by putting it in square brackets. (The square brackets are necessary to avoid name conflicts with the fixed fields of an entry).
- Indicate whether the field should be protected or not, a protected field will behave like a “password” field and its content will be visually hidden by dots.
- Validate the creation of the field by clicking “ok”.
- Now that the field is created, its associated type and options must be defined. The type is simply described by a string, the options are enclosed in braces, separated by commas. An option is in the form key:value. (e.g.
text {generator:true}
)
Here is a non-exhaustive list of formats and options that can be used. Feel free to look at the default templates generated by the system to understand how it works.
n : natural number
s : string
* : 0 or more
+ : 1 or more
/ : or
Text
To create an edit string or number field
type
text
options
generator:[true/false] -> allows to generate a password with the generator (WARNING : only works if the name of the field is [Password] because of the format restrictions of the basic plugin)
lines:[many/n+] -> max number of lines (WARNING : only a visual restriction for the text box)
default:[s*] -> default string in the field
example
text {generator:true}
List
To create a drop-down list to select an item
type
list
options
items:[s*(|s*)+] -> builds a list of strings
default:[s*] -> selects by default an item from the list
example
list {default:WPA2, items:WPA3|WPA2|WPA|WEP}
DateTime
To create a date / time selector
type
datetime
options
format:[date/time] -> restrict to the selection of a time or a date
example
datetime {format:date}
Divider
To separate the fields above and below into two sections
type
divider
no option
example
divider