none
[openafs-wiki.git] / TWiki / TWikiForms.mdwn
1 ## <a name="Form Templates"></a> Form Templates
2
3 <div>
4   <ul>
5     <li><a href="#Form Templates"> Form Templates</a><ul>
6         <li><a href="#Terminology"> Terminology</a></li>
7         <li><a href="#Specification"> Specification</a><ul>
8             <li><a href="#Enable forms for a web"> Enable forms for a web</a></li>
9             <li><a href="#Defining a form template"> Defining a form template</a></li>
10           </ul>
11         </li>
12         <li><a href="#Examples"> Examples</a><ul>
13             <li><a href="#Defining form in one topic"> Defining form in one topic</a></li>
14             <li><a href="#Defining form in multiple topics"> Defining form in multiple topics</a></li>
15             <li><a href="#Notes"> Notes</a></li>
16           </ul>
17         </li>
18         <li><a href="#Changes from category system"> Changes from category system</a></li>
19         <li><a href="#Creating new topics with forms"> Creating new topics with forms</a></li>
20         <li><a href="#Topic meta data"> Topic meta data</a></li>
21         <li><a href="#UI for multiple form templates"> UI for multiple form templates</a></li>
22         <li><a href="#Migration of Category informatio"> Migration of Category information</a></li>
23         <li><a href="#History"> History</a></li>
24       </ul>
25     </li>
26   </ul>
27 </div>
28
29 Topics allow for flexible free format data, sometimes you want to ensure strucutre to some of the topic information, this can be done with Forms e.g. saying what type of topic it is (Bug, Feature, FAQ entry etc).
30
31 ### <a name="Terminology"></a> Terminology
32
33 - **Form Template:** A set of fields defining a form. (_Class_ in OO speak; used to be called _category table definition_)
34   - A web may contain more then zero or more form template.
35 - **Form:** A topic containing additional meta-data (besides the free form TEXTAREA) which categorizes the content. (_Object_ in OO speak; used to be called _category table_)
36   - A topic has zero or one of the defined forms. So there are topics with a form or without.
37 - **Form Field:** A named item in a form. (Used to be called _category item name_)
38 - **Field Type:** The type of a field when editing a form. The type defines the HTML INPUT tag widgets when editing a topic:
39   - **select:** Drop down box or selector
40   - **checkbox:** One or more check boxes
41   - **checkbox+buttons:** One or more check boxes, plus _set_ and _clear_ buttons to set/clear all check boxes
42   - **radio:** One or more radio buttons
43   - **text:** A one-line text field
44   - **textarea:** A general text area - size is _rows_x_cols_ e.g. 40x10
45 - **Field Value:** Value of a form field. Can be one or more values from a fixed set (select, checkbox, radio type) or free form (text type). (Used to be called _category item value_)
46
47 ### <a name="Specification"></a> Specification
48
49 #### <a name="Enable forms for a web"></a> Enable forms for a web
50
51 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.
52
53 The <code>**WEBFORMS**</code> variable in [[WebPreferences]] is optional and defines a list of possible form templates e.g.
54
55 - Set WEBFORMS = BugForm, FeatureForm, BookLoanForm
56
57 With this present 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 to the right of the form name. The buttons leads to a screen that enables _no form_ to be selected of one of those specified by `WEBFORMS`.
58
59 A default form template (i.e. new topics get this default form) can be provided by creating the <code>**WebTopicEditTemplate**</code> topic in a Web and adding a form to it. Initial form values can be set here.
60
61 Addtionaly 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. Names being:
62
63 - Not checkboxs - nameFLD e.g. ?BugPriorityFLD=1
64 - Checkbox - nameFLDvalue=1 e.g. ?ColourFLDRed=1. Note that all boxes with a tick must be specified.
65
66 #### <a name="Defining a form template"></a> Defining a form template
67
68 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.
69
70 ### <a name="Examples"></a> Examples
71
72 #### <a name="Defining form in one topic"></a> Defining form in one topic
73
74 Example: WebFormTemplate of the TWiki.Know web:
75
76 <table border="1" cellpadding="0" cellspacing="0">
77   <tr>
78     <th bgcolor="#99CCCC"><strong> Name: </strong></th>
79     <th bgcolor="#99CCCC"><strong> Type: </strong></th>
80     <th bgcolor="#99CCCC"><strong> Size: </strong></th>
81     <th bgcolor="#99CCCC"><strong> Values: </strong></th>
82     <th bgcolor="#99CCCC"><strong> Tooltip message: </strong></th>
83   </tr>
84   <tr>
85     <td>[[Know/TopicClassification]]</td>
86     <td> select </td>
87     <td> 1 </td>
88     <td>[[Know/NoDisclosure]], [[Know/PublicSupported]], [[Know/PublicFAQ]]</td>
89     <td> blah blah... </td>
90   </tr>
91   <tr>
92     <td>[[Know/OperatingSystem]]</td>
93     <td> checkbox </td>
94     <td> 3 </td>
95     <td>[[Know/OsHPUX]], [[Know/OsLinux]], [[Know/OsSolaris]], [[Know/OsWin]]</td>
96     <td> blah blah... </td>
97   </tr>
98   <tr>
99     <td>[[Know/OsVersion]]</td>
100     <td> text </td>
101     <td> 16 </td>
102     <td>   </td>
103     <td> blah blah... </td>
104   </tr>
105 </table>
106
107 #### <a name="Defining form in multiple topics"></a> Defining form in multiple topics
108
109 The form template can also be defined in an alternative way by using more then one topic:
110
111 - A **form template topic** defines the form
112 - Values of fields that have more then one value, e.g. of type radio, select and checkbox can be defined by **field value template topics**
113
114 Above Example:
115
116 - WebFormTemplate of the TWiki.Know web: <table border="1" cellpadding="0" cellspacing="0">
117   <tr>
118     <th bgcolor="#99CCCC"><strong> Name: </strong></th>
119     <th bgcolor="#99CCCC"><strong> Type: </strong></th>
120     <th bgcolor="#99CCCC"><strong> Size: </strong></th>
121     <th bgcolor="#99CCCC"><strong> Values: </strong></th>
122     <th bgcolor="#99CCCC"><strong> Tooltip message: </strong></th>
123   </tr>
124   <tr>
125     <td>[[Know/TopicClassification]]</td>
126     <td> select </td>
127     <td> 1 </td>
128     <td>   </td>
129     <td> blah blah... </td>
130   </tr>
131   <tr>
132     <td>[[Know/OperatingSystem]]</td>
133     <td> checkbox </td>
134     <td> 3 </td>
135     <td>   </td>
136     <td> blah blah... </td>
137   </tr>
138   <tr>
139     <td>[[Know/OsVersion]]</td>
140     <td> text </td>
141     <td> 16 </td>
142     <td>   </td>
143     <td> blah blah... </td>
144   </tr>
145 </table>
146
147 - TopicClassification topic: <table border="1" cellpadding="0" cellspacing="0">
148   <tr>
149     <th bgcolor="#99CCCC"><strong> Name: </strong></th>
150     <th bgcolor="#99CCCC"><strong> Type: </strong></th>
151     <th bgcolor="#99CCCC"><strong> Tooltip message: </strong></th>
152   </tr>
153   <tr>
154     <td>[[Know/NoDisclosure]]</td>
155     <td> option </td>
156     <td> blah blah... </td>
157   </tr>
158   <tr>
159     <td>[[Know/PublicSupported]]</td>
160     <td> option </td>
161     <td> blah blah... </td>
162   </tr>
163   <tr>
164     <td>[[Know/PublicFAQ]]</td>
165     <td> option </td>
166     <td> blah blah... </td>
167   </tr>
168 </table>
169
170 #### <a name="Notes"></a> Notes
171
172 - This format allows you to define field items with / without [[WikiNames]], depending on your needs.
173 - The topic can be protected in the usual manner so that not everybody can change the form template - see [[TWikiAccessControl]]
174 - <code>[[...|/WebHome]]</code> can be used for force a link, at present <code>[[...|/WebHome]]</code> format is not supported
175 - The "Tooltip message:" column is used as a tool tip for the field name (only if field name is a [[WikiName]]) - you only see the tooltip on edit
176 - The first item in the list is the default item. Alternative initial values can be given in a topic template such as <code>**WebTopicEditTemplate**</code> or using fieldFLD=value or for checkboxes fieldFLDcheckbox=1 in URL
177 - The topic definition is not read when a topic is viewed
178
179 ### <a name="Changes from category system"></a> Changes from category system
180
181 Main changes from [[TWikiCategoryTable]]:
182
183 - Name changed in the hope that form is more readily understandable than category
184 - The templates for category view/edit have been dropped
185 - Forms are defined by topics, categories were defined in a template file
186 - A Web can have multiple forms, only one category was possible
187 - Form data is saved in meta variables - see [[MetaDataDefinition]], and render to HTML on viewing. Category data was stored as HTML
188 - The UseCategory radio button has gone, the replacement being the _Change_ form and _Add Form_ buttons.
189
190 ### <a name="Creating new topics with forms"></a> Creating new topics with forms
191
192 When you create a new topic in a web that has the WEBFORMS preferences variable set you will get a _Add Form_ button at the bottom of the page. However, if the [[WebTopicEditTemplate]] topic has had a form added this will appear with values set; _Change_ in the form can be pressed to remove the template or switch to a different one.
193
194 A form embedded in a topic can also cause a form to be present in a new topic, this is done by specifying the `formtemplate` parameter in the URL.
195
196 ### <a name="Topic meta data"></a> Topic meta data
197
198 See [[TWikiMetaDataDefinition]].
199
200 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.
201
202 The order of form field/value items in the meta-data is the same as in the form template.
203
204 ### <a name="UI for multiple form templates"></a> UI for multiple form templates
205
206 - Optional <code>**WEBFORMS**</code> variable defines possible form templates that can be selected after pressing "Change" (forms) button on edit page
207 - A template topic can use any form template
208 - Decided not to ask user to choose a template or form template when creating a topic as goes against the KISS of Wiki systems.
209 - New topics with a form get instantiated by simple HTML forms asking for a topic name, i.e. there is a SubmitExpenseReport topic were you can create new expense reports, a SubmitVacationRequest topic and so on. These can specify the required template topic and hence form.
210
211 ### <a name="Migration of Category informatio"></a> Migration of Category information
212
213 Principle: new system should work with old data with no special conversion.
214
215 Old data should be transparently upgraded to the new meta format when a topic is edit/previewed/saved.
216
217 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`. If it's not present `view` works, but `edit` results in an _oops_ dialog results. If things aren't working correctly there may be entries `data/warning.txt`.
218
219 ### <a name="History"></a> History
220
221 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.
222
223 -- [[JohnTalintyre]] - 16 Aug 2001 <br />