minor edit
[openafs-wiki.git] / TWiki / TWikiFormFieldDefinitionDotPm.mdwn
1 # <a name="Package &lt;code&gt;TWiki::Form::_FieldDefi"></a> Package =TWiki::Form::FieldDefinition
2
3 Base class of all field definition classes.
4
5 Type-specific classes are derived from this class to define specific per-type behaviours. This class also provides default behaviours for when a specific type cannot be loaded.
6
7 <div>
8   <ul>
9     <li><a href="#Package =TWiki::Form::_FieldDefi"> Package TWiki::Form::FieldDefinition</a><ul>
10         <li><a href="#ClassMethod <strong>new</strong> (%...)"> ClassMethod new <tt>(%...)</tt></a></li>
11         <li><a href="#ObjectMethod <strong>finish</strong> ()"> ObjectMethod finish <tt>()</tt></a></li>
12         <li><a href="#isEditable() -> $boolean"> isEditable() -&gt; $boolean</a></li>
13         <li><a href="#is_MultiValued() -> $boolean"> isMultiValued() -&gt; $boolean</a></li>
14         <li><a href="#is_TextMergeable() -> $boolean"> isTextMergeable() -&gt; $boolean</a></li>
15         <li><a href="#isMandatory() -> $boolean"> isMandatory() -&gt; $boolean</a></li>
16         <li><a href="#render_ForEdit( $web, $topic, $v"> renderForEdit( $web, $topic, $value ) -&gt; ($col0html, $col1html)</a></li>
17         <li><a href="#cssClasses(@classes) -> $classes"> cssClasses(@classes) -&gt; $classes</a></li>
18         <li><a href="#get_DefaultValue() -> $value"> getDefaultValue() -&gt; $value</a></li>
19         <li><a href="#renderHidden($meta) -> $html"> renderHidden($meta) -&gt; $html</a></li>
20         <li><a href="#populate_MetaDataFromQuery( $que"> populateMetaDataFromQuery( $query, $meta, $old ) -&gt; ($bValid, $bPresent)</a></li>
21         <li><a href="#ObjectMethod *render_ForDisplay*"> ObjectMethod renderForDisplay <tt>($format,$attrs) -&gt; $html</tt></a></li>
22       </ul>
23     </li>
24   </ul>
25 </div>
26
27 ## <a name="ClassMethod &lt;strong&gt;new&lt;/strong&gt; (%...)"></a> [[ClassMethod]] **new** `(%...)`
28
29 Construct a new [[FieldDefinition]]. Parameters are passed in a hash. See Form.pm for how it is called. Subclasses should pass @\_ on to this class.
30
31 ## <a name="ObjectMethod &lt;strong&gt;finish&lt;/strong&gt; ()"></a> [[ObjectMethod]] **finish** `()`
32
33 Break circular references.
34
35 ## <a name="isEditable() - $boolean"></a> isEditable() -&gt; $boolean
36
37 Is the field type editable? Labels aren't, for example. Subclasses may need to redefine this.
38
39 ## <a name="is_MultiValued() - $boolean"></a> isMultiValued() -&gt; $boolean
40
41 Is the field type multi-valued (i.e. does it store multiple values)? Subclasses may need to redefine this.
42
43 ## <a name="is_TextMergeable() - $boolean"></a> isTextMergeable() -&gt; $boolean
44
45 Is this field type mergeable using a conventional text merge?
46
47 ## <a name="isMandatory() - $boolean"></a> isMandatory() -&gt; $boolean
48
49 Is this field mandatory (required)?
50
51 ## <a name="render_ForEdit( $web, $topic, $v"></a> renderForEdit( $web, $topic, $value ) -&gt; ($col0html, $col1html)
52
53 `$web` - the web containing the topic being edited `$topic` - the topic being edited Render the field for editing. Returns two chunks of HTML; the `$col0html` is appended to the HTML for the first column in the form table, and the `$col1html` is used as the content of the second column.
54
55 ## <a name="cssClasses(@classes) - $classes"></a> cssClasses(@classes) -&gt; $classes
56
57 Construct a list of the CSS classes for the form field. Adds additional class specifiers related to the attributes of the field e.g mandatory. Pass it a list of the other classnames you want on the field.
58
59 ## <a name="get_DefaultValue() - $value"></a> getDefaultValue() -&gt; $value
60
61 Try and get a sensible default value for the field from the values stored in the form definition. The result should be a value string.
62
63 Some subclasses may not support the definition of defaults in the form definition. In that case this method should return `undef`.
64
65 ## <a name="renderHidden($meta) - $html"></a> renderHidden($meta) -&gt; $html
66
67 Render the form in `$meta` as a set of hidden fields.
68
69 ## <a name="populate_MetaDataFromQuery( $que"></a> populateMetaDataFromQuery( $query, $meta, $old ) -&gt; ($bValid, $bPresent)
70
71 Given a CGI `$query`, a `$meta` object, and an array of `$old` field entries, then populate the $meta with a row for this field definition, taking the content from the query if it's there, otherwise from $old or failing that, from the default defined for the type. Refuses to update mandatory fields that have an empty value.
72
73 Return $bValid true if the value in $meta was updated (either from the query or from a default in the form. Return $bPresent true if a value was present in the query (even it was undef)
74
75 ## <a name="ObjectMethod &lt;strong&gt;render_ForDisplay*"></a> [[ObjectMethod]] \*renderForDisplay `($format,$attrs) -> $html`
76
77 Render the field for display, under the control of $attrs.
78
79 The following vars in $format are expanded: $title - title of the form field $value - expanded to the **protected** value of the form field
80
81 The value is protected by TWiki::Render::protectFormFieldValue.