1 rizwank 1.1 %META:TOPICINFO{author="PeterThoeny" date="1095485413" format="1.0" version="1.21"}%
2 %META:TOPICPARENT{name="WebHome"}%
3 %TOC%
4 %STARTINCLUDE%
5 ---# TWiki Forms
6
7 _Form-based input in topics, with name/value pairs stored as Meta Data variables; choose one of multiple forms per web & topic_
8
9 ---++ Overview
10
11 By adding form-based input to freeform content, you can structure topics with unlimited, easily searchable categories. When forms are enabled for a web and selected in a topic, a single form appears in edit mode, and the contents are rendered as a table when viewed on the display page. You can define unlimited forms per web. For each topic, you can select a template if more than one is defined, or remove forms entirely. Form input values are stored as TWikiMetaData; all data is saved.
12
13 Form Templates replace <nop>TWikiCategoryTables from the 01-Dec-2000 version of TWiki. - see [[#FormsVsCategoryTables]]
14
15 ---++ Defining a Form Template
16
17 A Form Template is simply a page containing your form, defined as a table where each row is one form field.
18
19 ---+++ Form Template Elements
20
21 * *form template* - a set of fields defining a form
22 rizwank 1.1 * A web can use one or more form templates
23 * *form* - a topic containing additional meta data (besides the freeform TEXTAREA) that categorizes the content (replaces _category table_)
24 * Within a form-enabled web, individual topics can have a form or no form
25 * *form field* - a named item in a form (replaces _category item name_)
26 * *field type* - selects the INPUT type:
27 | *Input type* | *Type field* | *Size field* | *Value field* |
28 | One or more checkboxes | =checkbox= | number of checkboxes per line | comma list of checkbox labels |
29 | One or more checkboxes, plus *Set* and *Clear* buttons | =checkbox+buttons= | (same) | (same) |
30 | Read-only label text | =label= | =1= | (unused) |
31 | One or more radio buttons | =radio= | number of radio buttons per line | comma list of checkbox labels |
32 | Drop-down menu or scrollable box | =select= | =1= for drop down, =2= and up for scrollable box | comma list of options |
33 | A one-line text field | =text= | text box width in number of characters | (unused) |
34 | A text box; size is 40x10 (columns x rows) | =textarea= | columns x rows, e.g. =40x6= | (unused) |
35 * *field value* - one or more values from a fixed set (select, checkbox, radio type) or free-form (text). (replaces _category item value_)
36
37 ---+++ Defining a Form in One Topic
38
39 1. Create a new topic with your form name: ==<nop>YourForm==, ==<nop>ExpenseReportForm==, ==<nop>InfoCategoryForm==, ==<nop>RecordReviewForm==, whatever you need.
40 1. Create a TWiki table, with each column head representing one element of an entry field: ==Name==, ==Type==, ==Size==, ==Values==, and ==Tooltip message== _(see sample below)_.
41 1. For each field, fill in a new line; for the type of field, select from the list.
42 1. Save the topic _(you can later choose to [[#EnablingForms][enable/disable]] individual forms)_.
43 rizwank 1.1
44 <blockquote style="background-color:#f0f0f0">
45 *Example:* ==<nop>WebForm== %BR%
46 =| <nop>*Name* | <nop>*Type* | <nop>*Size* | <nop>*Values* | <nop>*Tooltip message* |= %BR%
47 =| !TopicClassification | select | 1 | !NoDisclosure, !PublicSupported, !PublicFAQ | blah blah... |= %BR%
48 =| !OperatingSystem | checkbox | 3 | !OsHPUX, !OsLinux, !OsSolaris, !OsWin | blah blah... |= %BR%
49 =| !OsVersion | text | 16 | | blah blah... |=
50
51 | *Name* | *Type* | *Size* | *Values* | *Tooltip message* |
52 | <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/TopicClassification"><nop>TopicClassification</a> | select | 1 | <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/NoDisclosure"><nop>NoDisclosure</a>, <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/PublicSupported"><nop>PublicSupported</a>, <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/PublicFAQ"><nop>PublicFAQ</a> | blah blah... |
53 | <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/OperatingSystem"><nop>OperatingSystem</a> | checkbox | 3 | <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/OsHPUX"><nop>OsHPUX</a>, <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/OsLinux"><nop>OsLinux</a>, <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/OsSolaris"><nop>OsSolaris</a>, <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/OsWin"><nop>OsWin</a> | blah blah... |
54 | <a href="%SCRIPTURL%/view%SCRIPTSUFFIX%/Sandbox/OsVersion"><nop>OsVersion</a> | text | 16 | | blah blah... |
55 </blockquote>
56
57 ---+++ Defining a Form with Multiple Topics
58
59 Forms can also be defined by using form templates that retrieve field values from one or more separate topics:
60
61 * A topic defines the base form, for example ==<nop>ExpenseReportForm==.
62 * Each field that has a value _list_ - select, radio, checkbox - can use a separate topic to define the available values.
63
64 rizwank 1.1 <blockquote style="background-color:#f0f0f0">
65 *Example: <nop>WebForm*
66
67 * ==WebForm== base form definition (as above, but with empty values):
68 %BR%
69 | *Name* | *Type* | *Size* | *Values* | *Tooltip message* |
70 | <nop>TopicClassification | select | 1 | | blah blah... |
71 | <nop>OperatingSystem | checkbox | 3 | | blah blah... |
72 | <nop>OsVersion | text | 16 | | blah blah... |
73 %BR%
74 %X% Leave the ==Values== field *blank*.
75
76 * <nop>TopicClassification field value definition in ==TopicClassification== topic: %BR%
77 =| <nop>*Name* | <nop>*Type* | <nop>*Tooltip message* |= %BR%
78 =| <nop>NoDisclosure | option | blah blah... |= %BR%
79 =| <nop>PublicSupported | option | blah blah... |= %BR%
80 =| <nop>PublicFAQ | option | blah blah... |= %BR%
81 %BR%
82 | *Name* | *Type* | *Tooltip message* |
83 | <nop>NoDisclosure | option | blah blah... |
84 | <nop>PublicSupported | option | blah blah... |
85 rizwank 1.1 | <nop>PublicFAQ | option | blah blah... |
86 </blockquote>
87
88 * *Implementation Notes:* This format allows you to define field items with or without TWiki.WikiNames, depending on your needs.
89 * Topics can be protected in the usual manner, using TWikiAccessControl, to limit who can change the form template and/or individual value lists.
90 * ==[<nop>[...]]== links can be used to force a link (at present, the ==[<nop>[...][...]]== format is not supported).
91 * The ==Tooltip message== column is used as a tooltip for the field name (only if field name is a %TWIKIWEB%.WikiName) - you only see the tooltip In edit.
92 * The first item in the list is the default item. Alternative initial values can be set in a topic template, like ==WebTopicEditTemplate==, with ==field=value==, or, for checkboxes, ==field<checkbox name>=1==.
93 * The topic definition is not read when a topic is viewed.
94
95 #EnablingForms
96 ---++ Enabling Forms by Web
97
98 Forms are enabled on a per web basis. The ==WEBFORMS== variable in WebPreferences is optional and defines a list of possible form templates. Example:
99 * <nop>Set WEBFORMS = <nop>BugForm, <nop>FeatureForm, <nop>BookLoanForm
100
101 * With ==WEBFORMS== enabled, an extra button is added to the edit view. If the topic doesn't have a Form, an *Add Form* button appears at the end of the topic. If a Form is present, a *Change* button appears in the top row of the Form. The buttons open a screen that enables selection of a form specified in =WEBFORMS=, or the *No form* option.
102
103 ---++ Including Forms in New Topics
104
105 * A default Form Template (new topics get this default form) can be provided by creating the =WebTopicEditTemplate= topic in a web and adding a form to it. Initial Form values can be set there.
106 rizwank 1.1
107 * Additionally a new topic can be given a Form using the =formtemplate= parameter in the URL. Initial values can then be provided in the URLs or as form values:
108 * other than checkboxes: ==name==, ex: ==?BugPriority=1==
109 * checkbox: ==namevalue=1==, ex: ==?ColorRed=1==. <br />
110 Boxes with a tick must be specified.
111
112 ---++ Setting Up Multiple Form Options
113
114 * The optional ==WEBFORMS== variable defines alternative forms that can be selected by pressing *Change* in edit mode.
115
116 * A topic template can use any form.
117
118 * New topics with a form are created by simple HTML forms asking for a topic name. For example, you can have a =<nop>SubmitExpenseReport= topic where you can create new expense reports, a =<nop>SubmitVacationRequest= topic, and so on. These can specify the required template topic with its associated form.
119
120 ---++ Form Data Storage
121
122 The form topic name, fields and values are stored as TWikiMetaData - the order of the field/value pairs is the same as in the template.
123
124 #UsingFormData
125 ---++ Using Form Data
126 TWikiForms accept user-input data, stored as TWikiMetaData. Meta data also contains program-generated info about changes, attachments, etc. To find, format and display form and other meta data, see TWikiMetaData, ==SEARCH== and ==METASEARCH== variables in TWikiVariables, and [[FormattedSearch][TWiki Formatted Search]] for various options.
127 rizwank 1.1
128 #FormsVsCategoryTables
129 ---++ Main Changes from Category Tables
130
131 The Form Template system is a more powerful, flexible replacement for the original <nop>TWikiCategoryTable. Data from existing category tables can be imported directly.
132
133 | *Form Templates* | *Category Tables* |
134 | defined in topics | defined in templates |
135 | many forms per web | one table per web |
136 | saved as Meta Data | saved as HTML |
137 | *Change* & *Add Form* buttons | *<nop>UseCategory* radio button |
138
139 ---+++ Importing Category Table Data
140
141 On upgrading from the previous TWiki, a Form Template topic has to be built for each web that used a Category Table, recreating the fields and values from the old ==twikicatitems.tmpl==. The replacement Form Template must be set as the first item in the WebPreferences variable =WEBFORMS=. If missing, pages will display, but attempting to edit results in an error message.
142
143 The new Form Template system should work with old Category Table data with no special conversion. Data is assigned to Meta variables the first time an imported topic is edited and saved in the new system.
144
145 %T% *NOTE:* If things aren't working correctly, there may be useful entries in =data/warning.txt=.
146
147 ---++ Using Forms For Settings
148 rizwank 1.1 Example process to change your WebPreferences to use forms instead of ={3 spaces}* Set= statements:
149
150 1 create !WebPrefencesForm topic
151 2 fill it with a table like this: %BR%
152 =| *Name*|*Type*|*Size*|*Value*|*Tooltip message*|*Attributes*|= %BR%
153 =| WEBTOPICLIST |textarea| | | List of topics of the !%WEB% web |S|= %BR%
154 =| SITEMAPLIST |select |3| on, | list this web in the Site Map |S|= %BR%
155 =| SITEMAPWHAT |textarea| | | short web summary |S|= %BR%
156 =| WEBBGCOLOR |text |8| | Web specific background color |S|= %BR%
157 etc...
158 3 Edit WebPreferences and:
159 * Add or Change the form to !WebPrefencesForm
160 * add !WebPrefencesForm to the =Set WEBFORMS= line
161 * Save
162 4 Edit WebPreferences, jump straight down to the form ignoring all the =textarea= stuff, and set as you like
163 5 if everything works as you like it, you can delete the Set statements (the form overrides set if they are both used).
164
165 __Notes:__
166
167 If it isn't working, double check that the ==S== attribute has been specified (S for Setting).
168 If you change the form, the changes will not take affect until you edit and save the preferences' topics again.
169 rizwank 1.1
170 Using the TWiki:Plugins.EditTablePlugin on !WebPreferencesForm makes adding new prefedrences a breeze.
171
172 A possibly unwanted side effect for using forms for the SKINS setting in their personal user topic: because the User Preferences are final you can't have different skins for different webs as the user's setting always wins. A workaround is to simply omit SKIN in the form.
173
174 Another example, this one using !EditTablePlugin, source:
175
176 =%<nop>EDITTABLE{ header="|*Name*|*Type*|*Size*|*Values*|*Tooltip message*|*Attributes*|" format="|text,20|text,20|text,20|text,20|text,20|text,1|" }%=
177
178 Result (after some editing):
179
180 %EDITTABLE{ header="|*Name*|*Type*|*Size*|*Values*|*Tooltip message*|*Attributes*|" format="|text,20|text,20|text,20|text,20|text,20|text,1|" }%
181 |*Name* | *Type* | *Size* | *Values* | *tooltip message* | *Attributes*|
182 |ALLOWTOPICCHANGE | textarea | | | Users or groups __allowed__ to change or rename this <nop>%TOPIC% topic: (I.e. %MAINWEB%.TWikiAdminGroup) | S|
183 |ALLOWWEBCHANGE | textarea | | | Users or groups who __are__ allowed to __change__ topics in the <nop>%WEB% web: (See %TWIKIWEB%.TWikiAccessControl) | S|
184 |ALLOWWEBRENAME | textarea | | %MAINWEB%.TWikiAdminGroup | Users or groups who __are__ allowed to __rename__ topics in the <nop>%WEB% web: (See %TWIKIWEB%.TWikiAccessControl) | S|
185 |ALLOWWEBVIEW | textarea | | | Users or groups who __are__ allowed to __view__ topics in the <nop>%WEB% web: (See %TWIKIWEB%.TWikiAccessControl) | S|
186 |DENYWEBCHANGE | textarea | | | Users or groups who __are not__ allowed to __change__ topics in the <nop>%WEB% web: (See %TWIKIWEB%.TWikiAccessControl) | S|
187 |DENYWEBRENAME | textarea | | | Users or groups who __are not__ allowed to __rename__ topics in the <nop>%WEB% web: (See %TWIKIWEB%.TWikiAccessControl) | S|
188 |DENYWEBVIEW | textarea | | | Users or groups who __are not__ allowed to __view__ topics in the <nop>%WEB% web: (See %TWIKIWEB%.TWikiAccessControl) | S|
189 |FINALPREFERENCES | textarea | | "NOSEARCHALL, ATTACHFILESIZELIMIT, WIKIWEBMASTER, WEBCOPYRIGHT, WEBTOPICLIST, DENYWEBVIEW, ALLOWWEBVIEW, DENYWEBCHANGE, ALLOWWEBCHANGE, DENYWEBRENAME, ALLOWWEBRENAME" | Web preferences that are *not* allowed to be overridden by user preferences | S|
190 rizwank 1.1 |NOSEARCHALL | text | | ",on" | "Exclude web from a =web=""all""= search: (Set to =on= for hidden webs)" | S|
191 |SITEMAPLIST | select | | "on, ," | List this web in the %TWIKIWEB%.SiteMap | S|
192 |SITEMAPUSETO | textarea | | ...to do something. | ...to do something. | S|
193 |SITEMAPWHAT | textarea | | Describe what this web does. | Describe what this web does. | |
194 |SKIN | select | | "twiki, free, gnu, koala, pattern, plain, tiger" | list of installed skins | S|
195 |WEBBGCOLOR | select | | lightpink, pink, crimson, lavenderblush, palevioletred, hotpink, deeppink, mediumvioletred, orchid, thistle, plum, violet, fuchsia, fuchsia, darkmagenta, purple, mediumorchid, darkviolet, darkorchid, indigo, blueviolet, mediumpurple, mediumslateblue, slateblue, darkslateblue, ghostwhite, lavender, blue, mediumblue, darkblue, navy, midnightblue, royalblue, cornflowerblue, lightsteelblue, lightslategray, slategray, dodgerblue, aliceblue, steelblue, lightskyblue, skyblue, deepskyblue, lightblue, powderblue, cadetblue, darkturquoise, azure, lightcyan, paleturquoise, aqua, aqua, darkcyan, teal, darkslategray, mediumturquoise, lightseagreen, turquoise, aquamarine, mediumaquamarine, mediumspringgreen, mintcream, springgreen, mediumseagreen, seagreen, honeydew, darkseagreen, palegreen, lightgreen, limegreen, lime, forestgreen, green, darkgreen, lawngreen, chartreuse, greenyellow, darkolivegreen, yellowgreen, olivedrab, ivory, beige, lightyellow, lightgoldenrodyellow, yellow, olive, darkkhaki, palegoldenrod, lemonchiffon, khaki, gold, cornsilk, goldenrod, darkgoldenrod, floralwhite, oldlace, wheat, orange, moccasin, papayawhip, blanchedalmond, navajowhite, antiquewhite, tan, burlywood, darkorange, bisque, linen, peru, peachpuff, sandybrown, chocolate, saddlebrown, seashell, sienna, lightsalmon, coral, orangered, darksalmon, tomato, salmon, mistyrose, lightcoral, snow, rosybrown, indianred, red, brown, firebrick, darkred, maroon, white, whitesmoke, gainsboro, lightgrey, silver, darkgray, gray, dimgray, black | Web specific background color: (Pick a lighter one of the %TWIKIWEB%.StandardColors) | S|
196 |WEBFORMS | textarea | | | %TWIKIWEB%.TWikiForms: How to enable form(s) | S|
197 |WEBTOPICLIST | textarea | | [[WebHome]], [[WebChanges][Changes]], [[WebTopicList][Topics]], [[WebIndex][Index]], [[WebSearch][Search]], Go <input type="text" name="topic" size="16" /> | the main entry point topics for this web | S|
198
199
200 -- TWiki:Main.JohnTalintyre - 16 Aug 2001 %BR%
201 -- TWiki:Main.MikeMannix - 05 Jan 2002 %BR%
202 -- TWiki:Main.PeterThoeny - 25 Apr 2004 %BR%
203 -- TWiki:Main.MattWilkie - 27 Jul 2004 %BR%
204 %STOPINCLUDE%
205
206 %META:TOPICMOVED{by="MikeMannix" date="1000277489" from="TWiki.TWikiFormTemplate" to="TWiki.TWikiForms"}%
|