buildrelease
[openafs-wiki.git] / TWiki / TWikiFormDotPm.mdwn
index b7d3a66..a3c26f8 100644 (file)
@@ -2,19 +2,24 @@
 
 Object representing a single form definition.
 
+Form definitions are mainly used to control rendering of a form for editing, though there is some application login there that handles transferring values between edits and saves.
+
+A form definition consists of a TWiki::Form object, which has a list of field definitions. Each field definition is an object of a type derived from TWiki::Form::FieldDefinition. These objects are responsible for the actual syntax and semantics of the field type. Form definitions are parsed from TWiki tables, and the types are mapped by name to a class declared in TWiki::Form::\* - for example, the `text` type is mapped to `TWiki::Form::Text` and the `checkbox` type to `TWiki::Form::Checkbox`.
+
+The `TWiki::Form::FieldDefinition` class declares default behaviours for types that accept a single value in their definitions. The `TWiki::Form::ListFieldDefinition` extends this for types that have lists of possible values.
+
 <div>
   <ul>
     <li><a href="#Package =TWiki::Form="> Package TWiki::Form</a><ul>
         <li><a href="#ClassMethod <strong>new</strong> ($session,$web"> ClassMethod new <tt>($session,$web,$form,$def)</tt></a></li>
+        <li><a href="#ObjectMethod <strong>finish</strong> ()"> ObjectMethod finish <tt>()</tt></a></li>
+        <li><a href="#StaticMethod *field_Title2FieldN"> StaticMethod fieldTitle2FieldName <tt>($title) -&gt; $name</tt></a></li>
         <li><a href="#ObjectMethod <strong>render_ForEdit</strong> ($"> ObjectMethod renderForEdit <tt>($web,$topic,$meta) -&gt; $html</tt></a></li>
-        <li><a href="#ObjectMethod *render_FieldForEdi"> ObjectMethod renderFieldForEdit <tt>($fieldDef,$web,$topic,$value) -&gt; $html</tt></a></li>
         <li><a href="#ObjectMethod <strong>renderHidden</strong> ($me"> ObjectMethod renderHidden <tt>($meta) -&gt; $html</tt></a></li>
-        <li><a href="#ObjectMethod <strong>cgiName</strong> ($field)"> ObjectMethod cgiName <tt>($field) -&gt; $string</tt></a></li>
         <li><a href="#ObjectMethod *get_FieldValuesFro"> ObjectMethod getFieldValuesFromQuery <tt>($query,$metaObject) -&gt; ($seen,\@missing)</tt></a></li>
         <li><a href="#ObjectMethod *is_TextMergeable*"> ObjectMethod isTextMergeable <tt>($name) -&gt; $boolean</tt></a></li>
-        <li><a href="#ObjectMethod <strong>getField</strong> ($name)"> ObjectMethod getField <tt>($name) -&gt; \%row</tt></a></li>
+        <li><a href="#ObjectMethod <strong>getField</strong> ($name)"> ObjectMethod getField <tt>($name) -&gt; $fieldDefinition</tt></a></li>
         <li><a href="#ObjectMethod <strong>getFields</strong> () -> \"> ObjectMethod getFields <tt>() -&gt; \@fields</tt></a></li>
-        <li><a href="#StaticMethod *render_ForDisplay*"> StaticMethod renderForDisplay <tt>($templates,$meta)</tt></a></li>
       </ul>
     </li>
   </ul>
@@ -22,39 +27,34 @@ Object representing a single form definition.
 
 ## <a name="ClassMethod &lt;strong&gt;new&lt;/strong&gt; ($session,$web"></a> [[ClassMethod]] **new** `($session,$web,$form,$def)`
 
+Looks up a form in the session object or, if it hasn't been read yet, reads it frm the form definition topic on disc.
+
 - $web - default web to recover form from, if $form doesn't specify a web
 - `$form` - topic name to read form definition from
 - `$def` - optional. a reference to a list of field definitions. if present, these definitions will be used, rather than those in `$form`.
 
 May throw TWiki::OopsException
 
-## <a name="ObjectMethod &lt;strong&gt;render_ForEdit&lt;/strong&gt; ($"></a> [[ObjectMethod]] **renderForEdit** `($web,$topic,$meta) -> $html`
+## <a name="ObjectMethod &lt;strong&gt;finish&lt;/strong&gt; ()"></a> [[ObjectMethod]] **finish** `()`
 
-- `$web` the web of the topic being rendered
-- `$topic` the topic being rendered
-- `$meta` the meta data for the form
+Break circular references.
 
-Render the form fields for entry during an edit session, using data values from $meta
+## <a name="StaticMethod &lt;strong&gt;field_Title2FieldN"></a> [[StaticMethod]] \*fieldTitle2FieldName `($title) -> $name`
+
+Chop out all except A-Za-z0-9\_. from a field name to create a valid "name" for storing in meta-data
 
-## <a name="ObjectMethod &lt;strong&gt;render_FieldForEdi"></a> [[ObjectMethod]] \*renderFieldForEdit `($fieldDef,$web,$topic,$value) -> $html`
+## <a name="ObjectMethod &lt;strong&gt;render_ForEdit&lt;/strong&gt; ($"></a> [[ObjectMethod]] **renderForEdit** `($web,$topic,$meta) -> $html`
 
-- `$fieldDef` the field being rendered
 - `$web` the web of the topic being rendered
 - `$topic` the topic being rendered
-- `$value` the current value of the field
-
-Render a single form field for entry during an edit session, using data values from $meta. Plugins can provide a handler that extends the set of supported types
+- `$meta` the meta data for the form
 
-SMELL: this should be a method on a field class
+Render the form fields for entry during an edit session, using data values from $meta
 
 ## <a name="ObjectMethod &lt;strong&gt;renderHidden&lt;/strong&gt; ($me"></a> [[ObjectMethod]] **renderHidden** `($meta) -> $html`
 
 Render form fields found in the meta as hidden inputs, so they pass through edits untouched.
 
-## <a name="ObjectMethod &lt;strong&gt;cgiName&lt;/strong&gt; ($field)"></a><a name="ObjectMethod &lt;strong&gt;cgiName&lt;/strong&gt; ($field) "></a> [[ObjectMethod]] **cgiName** `($field) -> $string`
-
-Generate the 'name' of the CGI parameter used to represent a field.
-
 ## <a name="ObjectMethod &lt;strong&gt;get_FieldValuesFro"></a> [[ObjectMethod]] \*getFieldValuesFromQuery `($query,$metaObject) -> ($seen,\@missing)`
 
 Extract new values for form fields from a query.
@@ -74,21 +74,12 @@ Returns true if the type of the named field allows it to be text-merged.
 
 If the form does not define the field, it is assumed to be mergeable.
 
-## <a name="ObjectMethod &lt;strong&gt;getField&lt;/strong&gt; ($name)"></a><a name="ObjectMethod &lt;strong&gt;getField&lt;/strong&gt; ($name) "></a> [[ObjectMethod]] **getField** `($name) -> \%row`
+## <a name="ObjectMethod &lt;strong&gt;getField&lt;/strong&gt; ($name)"></a><a name="ObjectMethod &lt;strong&gt;getField&lt;/strong&gt; ($name) "></a> [[ObjectMethod]] **getField** `($name) -> $fieldDefinition`
 
 - `$name` - name of a form field (value of the `name` attribute)
 
-Returns the field, or undef if the form does not define the field.
+Returns a `TWiki::Form::FieldDefinition`, or undef if the form does not define the field.
 
 ## <a name="ObjectMethod &lt;strong&gt;getFields&lt;/strong&gt; () - \@"></a> [[ObjectMethod]] **getFields** `() -> \@fields`
 
 Return a list containing references to field name/value pairs. Each entry in the list has a \{name\} field and a \{value\} field. It may have other fields as well, which caller should ignore. The returned list should be treated as **read only** (must not be written to).
-
-## <a name="StaticMethod &lt;strong&gt;render_ForDisplay*"></a> [[StaticMethod]] \*renderForDisplay `($templates,$meta)`
-
-- `$templates` ref to templates singleton
-- `$meta` - meta object containing the form to be rendered
-
-Static because we want to be able to do this without a form definition.
-
-SMELL: Why? Is reading the form topic such a big burden?