none
[openafs-wiki.git] / TWiki / TWikiForms.mdwn
1 <div>
2   <ul>
3     <li><a href="#TWiki Forms"> TWiki Forms</a><ul>
4         <li><a href="#Overview"> Overview</a></li>
5         <li><a href="#Defining a Form Template"> Defining a Form Template</a><ul>
6             <li><a href="#Form Template Elements"> Form Template Elements</a></li>
7             <li><a href="#Defining a Form in One Topic"> Defining a Form in One Topic</a></li>
8             <li><a href="#Defining a Form with Multiple To"> Defining a Form with Multiple Topics</a></li>
9           </ul>
10         </li>
11         <li><a href="#Enabling Forms by Web"> Enabling Forms by Web</a></li>
12         <li><a href="#Including Forms in New Topics"> Including Forms in New Topics</a></li>
13         <li><a href="#Setting Up Multiple Form Options"> Setting Up Multiple Form Options</a></li>
14         <li><a href="#Form Data Storage"> Form Data Storage</a></li>
15         <li><a href="#Using Form Data"> Using Form Data</a></li>
16         <li><a href="#Main Changes from Category Table"> Main Changes from Category Tables</a><ul>
17             <li><a href="#Importing Category Table Data"> Importing Category Table Data</a></li>
18           </ul>
19         </li>
20       </ul>
21     </li>
22   </ul>
23 </div>
24
25 # <a name="TWiki Forms"></a> TWiki Forms
26
27 _Form-based input in topics, with name/value pairs stored as Meta Data variables; choose one of multiple forms per web &amp; topic_
28
29 ## <a name="Overview"></a> Overview
30
31 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.
32
33 Form Templates replace TWikiCategoryTables from the 01-Dec-2000 version of TWiki. - see [[#FormsVsCategoryTables|Main/WebHome#FormsVsCategoryTables]]
34
35 ## <a name="Defining a Form Template"></a> Defining a Form Template
36
37 A Form Template is simply a page containing your form, defined as a table where each row is one form field.
38
39 ### <a name="Form Template Elements"></a> Form Template Elements
40
41 - **form template** - a set of fields defining a form (replaces _category table definition_)
42   - A web can use one or more form templates
43 - **form** - a topic containing additional meta data (besides the freeform TEXTAREA) that categorizes the content (replaces _category table_)
44   - Within a form-enabled web, individual topics can have a form or no form
45 - **form field** - a named item in a form (replaces _category item name_)
46 - **field type** - selects the INPUT type:
47   - **select** - drop-down menu or scrollable box
48   - **checkbox** - one or more checkboxes
49   - **checkbox+buttons** - one or more checkboxes, plus **Set** and **Clear** buttons
50   - **radio** - one or more radio buttons
51   - **text** - a one-line text field
52   - **textarea** - a text box; size is 40x10 (columns x rows)
53 - **field value** - one or more values from a fixed set (select, checkbox, radio type) or free-form (text). (replaces _category item value_)
54
55 ### <a name="Defining a Form in One Topic"></a> Defining a Form in One Topic
56
57 1. Create a new topic with your form name: <code>**YourForm**</code>, <code>**ExpenseReport**</code>, <code>**InfoCategory**</code>, <code>**RecordReview**</code>, whatever you need.
58 2. Create a TWiki table, with each column head representing one element of an entry field: <code>**Name**</code>, <code>**Type**</code>, <code>**Size**</code>, <code>**Values**</code>, and <code>**Tooltip message**</code> _(see sample below)_.
59 3. For each field, fill in a new line; for the type of field, select from the list.
60 4. Save the topic _(you can later choose to [[enable/disable|Main/WebHome#EnablingForms]] individual forms)_.
61
62 > **Example:**
63 >
64 > <code>**WebForm**</code>
65 >
66 >     | *Name* | *Type* | *Size* | *Values* | *Tooltip message* |
67 >     | Know.TopicClassification | select | 1 | Know.NoDisclosure,
68 >       Know.PublicSupported, Know.PublicFAQ | blah blah... |
69 >     | Know.OperatingSystem | checkbox | 3 | Know.OsHPUX, Know.OsLinux,
70 >       Know.OsSolaris, Know.OsWin | blah blah... |
71 >     | Know.OsVersion | text | 16 | | blah blah... |
72 >
73 > <table border="1" cellpadding="0" cellspacing="0">
74 >   <tr>
75 >     <th bgcolor="#99CCCC"><strong> Name </strong></th>
76 >     <th bgcolor="#99CCCC"><strong> Type </strong></th>
77 >     <th bgcolor="#99CCCC"><strong> Size </strong></th>
78 >     <th bgcolor="#99CCCC"><strong> Values </strong></th>
79 >     <th bgcolor="#99CCCC"><strong> Tooltip message </strong></th>
80 >   </tr>
81 >   <tr>
82 >     <td>[[Know/TopicClassification]]</td>
83 >     <td> select </td>
84 >     <td align="center"> 1 </td>
85 >     <td>[[Know/NoDisclosure]], [[Know/PublicSupported]], [[Know/PublicFAQ]]</td>
86 >     <td> blah blah... </td>
87 >   </tr>
88 >   <tr>
89 >     <td>[[Know/OperatingSystem]]</td>
90 >     <td> checkbox </td>
91 >     <td align="center"> 3 </td>
92 >     <td>[[Know/OsHPUX]], [[Know/OsLinux]], [[Know/OsSolaris]], [[Know/OsWin]]</td>
93 >     <td> blah blah... </td>
94 >   </tr>
95 >   <tr>
96 >     <td>[[Know/OsVersion]]</td>
97 >     <td> text </td>
98 >     <td align="center"> 16 </td>
99 >     <td>   </td>
100 >     <td> blah blah... </td>
101 >   </tr>
102 > </table>
103
104 ### <a name="Defining a Form with Multiple To"></a> Defining a Form with Multiple Topics
105
106 Forms can also be defined by using form templates that retrieve field values from one or more separate topics:
107
108 - A <code>**FormTemplate**</code> topic defines the Form, ex: <code>**YourFormTemplate**</code>.
109 - For each field that has a value list - select, radio, checkbox - can use separate topic to define the available values.
110
111 > **Example: WebFormTemplate**
112 >
113 > - Know.WebFormTemplate main definition: <br />   <table border="1" cellpadding="0" cellspacing="0">
114 >   <tr>
115 >     <th bgcolor="#99CCCC"><strong> Name </strong></th>
116 >     <th bgcolor="#99CCCC"><strong> Type </strong></th>
117 >     <th bgcolor="#99CCCC"><strong> Size </strong></th>
118 >     <th bgcolor="#99CCCC"><strong> Values </strong></th>
119 >     <th bgcolor="#99CCCC"><strong> Tooltip message </strong></th>
120 >   </tr>
121 >   <tr>
122 >     <td>[[Know/TopicClassification]]</td>
123 >     <td> select </td>
124 >     <td> 1 </td>
125 >     <td>   </td>
126 >     <td> blah blah... </td>
127 >   </tr>
128 >   <tr>
129 >     <td>[[Know/OperatingSystem]]</td>
130 >     <td> checkbox </td>
131 >     <td> 3 </td>
132 >     <td>   </td>
133 >     <td> blah blah... </td>
134 >   </tr>
135 >   <tr>
136 >     <td>[[Know/OsVersion]]</td>
137 >     <td> text </td>
138 >     <td> 16 </td>
139 >     <td>   </td>
140 >     <td> blah blah... </td>
141 >   </tr>
142 > </table>
143 > <br /> %X% Leave the <code>**Values**</code> field **blank**.
144 >
145 > - Know.TopicClassification field value definition: <br />   <table border="1" cellpadding="0" cellspacing="0">
146 >   <tr>
147 >     <th bgcolor="#99CCCC"><strong> Name </strong></th>
148 >     <th bgcolor="#99CCCC"><strong> Type </strong></th>
149 >     <th bgcolor="#99CCCC"><strong> Tooltip message </strong></th>
150 >   </tr>
151 >   <tr>
152 >     <td>[[Know/NoDisclosure]]</td>
153 >     <td> option </td>
154 >     <td> blah blah... </td>
155 >   </tr>
156 >   <tr>
157 >     <td>[[Know/PublicSupported]]</td>
158 >     <td> option </td>
159 >     <td> blah blah... </td>
160 >   </tr>
161 >   <tr>
162 >     <td>[[Know/PublicFAQ]]</td>
163 >     <td> option </td>
164 >     <td> blah blah... </td>
165 >   </tr>
166 > </table>
167
168 - **Implementation Notes:** This format allows you to define field items with or without [[WikiNames]], depending on your needs.
169   - Topics can be protected in the usual manner, using [[TWikiAccessControl]], to limit who can change the form template and/or individual value lists.
170   - <code>**\[[...]]**</code> links can be used to force a link (at present, the <code>**\[[...]\[...]]**</code> format is not supported).
171   - The <code>**Tooltip message**</code> column is used as a tooltip for the field name (only if field name is a [[WikiName]]) - you only see the tooltip In edit.
172   - The first item in the list is the default item. Alternative initial values can be set in a topic template, like <code>**WebTopicEditTemplate**</code>, with <code>**field=value**</code>, or, for checkboxes, <code>**field=1**</code>.
173   - The topic definition is not read when a topic is viewed.
174
175 <a name="EnablingForms"></a>
176
177 ## <a name="Enabling Forms by Web"></a> Enabling Forms by Web
178
179 Forms are enabled on a per web basis. The <code>**WEBFORMS**</code> variable in [[WebPreferences]] is optional and defines a list of possible form templates. Example:
180
181 - Set WEBFORMS = BugForm, FeatureForm, BookLoanForm
182
183 - With <code>**WEBFORMS**</code> 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.
184
185 ## <a name="Including Forms in New Topics"></a> Including Forms in New Topics
186
187 - 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.
188
189 - 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:
190   - other than checkboxes: <code>**name**</code>, ex: <code>**?BugPriority=1**</code>
191   - checkbox: <code>**namevalue=1**</code>, ex: <code>**?ColourRed=1**</code>. <br /> Boxes with a tick must be specified.
192
193 ## <a name="Setting Up Multiple Form Options"></a> Setting Up Multiple Form Options
194
195 - The optional <code>**WEBFORMS**</code> variable defines alternative forms that can be selected by pressing **Change** in edit mode.
196
197 - A topic template can use any form.
198
199 - New topics with a form are created by simple HTML forms asking for a topic name. For example, you can have a `SubmitExpenseReport` topic where you can create new expense reports, a `SubmitVacationRequest` topic, and so on. These can specify the required template topic with its associated form.
200
201 ## <a name="Form Data Storage"></a> Form Data Storage
202
203 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.
204
205 <a name="UsingFormData"></a>
206
207 ## <a name="Using Form Data"></a> Using Form Data
208
209 [[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]], <code>**SEARCH**</code> and <code>**METASEARCH**</code> variables in [[TWikiVariables]], and [[TWiki Formatted Search|Main/FormattedSearch]] for various options.
210
211 <a name="FormsVsCategoryTables"></a>
212
213 ## <a name="Main Changes from Category Table"></a> Main Changes from Category Tables
214
215 The Form Template system is a more powerful, flexible replacement for the original TWikiCategoryTable. Data from existing category tables can be imported directly.
216
217 <table border="1" cellpadding="0" cellspacing="0">
218   <tr>
219     <th align="center" bgcolor="#99CCCC"><strong> Form Templates </strong></th>
220     <th align="center" bgcolor="#99CCCC"><strong> Category Tables </strong></th>
221   </tr>
222   <tr>
223     <td align="center"> defined in topics </td>
224     <td align="center"> defined in templates </td>
225   </tr>
226   <tr>
227     <td align="center"> many forms per web </td>
228     <td align="center"> one table per web </td>
229   </tr>
230   <tr>
231     <td align="center"> saved as Meta Data </td>
232     <td align="center"> saved as HTML </td>
233   </tr>
234   <tr>
235     <td align="center"><strong>Change</strong> &amp; <strong>Add Form</strong> buttons </td>
236     <td align="center"><strong>UseCategory</strong> radio button </td>
237   </tr>
238 </table>
239
240 ### <a name="Importing Category Table Data"></a> Importing Category Table Data
241
242 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 <code>**twikicatitems.tmpl**</code>. 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.
243
244 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.
245
246 %T% **NOTE:** If things aren't working correctly, there may be useful entries in `data/warning.txt`.
247
248 -- [[JohnTalintyre]] - 16 Aug 2001 <br /> -- [[MikeMannix]] - 05 Jan 2002