Form Templates

Background

This is a more general replacement for the TWikiCategoryTable capability, in particular Forms are defined by special topics, where as categories were defineind using special templates.

Terminology

Specification

Enable forms for a web

By default topics can be edited in free form. A form can be added to a topic to give it more structure. Forms are enabled on a per web basis. This can be done in two ways. One is similar to that used for the older category system, with this a Web can have only one form. The other allows a Web to have any number of forms.

A default form template can be provided by creating the WebTopicEditTemplate topic in a Web and adding a form to it. Initial form values can be set here.

Enabling single default form

The DEFAULTFORM variable in WebPreferences is optional. If present it specifies the default form for all topics in the Web. Every time you edit a topic you will be presented with a form. The form must contain the special field UseForm (analogous to the UseCategory line in the old category system). The values for this must be:

Enabling multiple forms

The WEBFORMS variable in WebPreferences is optional and defines a list of possible form templates e.g.

With this present an extra button is added to the edit view. If the topic doesn't have a form the button appears at the end of the page. If a form is present the button appears in the top row of the form. Pressing the button leads to a screen that enables no form to be selected of one of those specified by WEBFORMS.

Define a form template

Form templates are defined by topics, one topic per form template. A form template topic has descriptive text mixed with the form template definition in the form of a TWiki table.

Examples

Defining form in one topic

Example: WebFormTemplate of the TWiki.Know web:

Name: Type: Size: Values: Tooltip message:
UseForm? radio 0 Yes, No Select 'No' to remove the form
TopicClassification? select 1 NoDisclosure?, PublicSupported?, PublicFAQ? blah blah...
OperatingSystem? checkbox 3 OsHPUX?, OsLinux?, OsSolaris?, OsWin? blah blah...
OsVersion? text 16   blah blah...

Defining form in multiple topics

The form template can also be defined in an alternative way by using more then one topic:

Above Example:

Notes

Changes from category system

Main changes from TWikiCategoryTable:

Creating new topics with forms

When you create a new topic in a web that has the WEBFORM preferences variable set you will get a topic with the default form template specified by the variable.

For simplicity we should use the default form template when one creates a new topic by question mark link or "Go" field, i.e. better not to show a menu to select a form template.

Topic meta data

See TWikiMetaDataDefinition?.

The form template topic name and all form fields/values are stored in the topic meta data. The form template topic name is needed for edit and save.

The order of form field/value items in the meta-data is the same as in the form template.

UI for multiple form templates

Migration of Category information

Principle: new system should work with old data with no special conversion.

Old data should be transparently upgraded to the new meta format when a topic is edit/previewed/saved.

On upgrading the administrator must produce a form template topic for each Web that using the old category system. twikicatitems.tmpl defines the categories and is used in the conversion. The form template must be put as first item in WebPreferences variable WEBFORM or DEFAULTFORM (if/when put in). If it's not present, an oops dialog results.

-- JohnTalintyre? - 07 Aug 2001