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