1 # <a name="Package <code>TWiki::Form::_FieldDefi"></a> Package =TWiki::Form::FieldDefinition
3 Base class of all field definition classes.
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.
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() -> $boolean</a></li>
13 <li><a href="#is_MultiValued() -> $boolean"> isMultiValued() -> $boolean</a></li>
14 <li><a href="#is_TextMergeable() -> $boolean"> isTextMergeable() -> $boolean</a></li>
15 <li><a href="#isMandatory() -> $boolean"> isMandatory() -> $boolean</a></li>
16 <li><a href="#render_ForEdit( $web, $topic, $v"> renderForEdit( $web, $topic, $value ) -> ($col0html, $col1html)</a></li>
17 <li><a href="#cssClasses(@classes) -> $classes"> cssClasses(@classes) -> $classes</a></li>
18 <li><a href="#get_DefaultValue() -> $value"> getDefaultValue() -> $value</a></li>
19 <li><a href="#renderHidden($meta) -> $html"> renderHidden($meta) -> $html</a></li>
20 <li><a href="#populate_MetaDataFromQuery( $que"> populateMetaDataFromQuery( $query, $meta, $old ) -> ($bValid, $bPresent)</a></li>
21 <li><a href="#ObjectMethod *render_ForDisplay*"> ObjectMethod renderForDisplay <tt>($format,$attrs) -> $html</tt></a></li>
27 ## <a name="ClassMethod <strong>new</strong> (%...)"></a> [[ClassMethod]] **new** `(%...)`
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.
31 ## <a name="ObjectMethod <strong>finish</strong> ()"></a> [[ObjectMethod]] **finish** `()`
33 Break circular references.
35 ## <a name="isEditable() - $boolean"></a> isEditable() -> $boolean
37 Is the field type editable? Labels aren't, for example. Subclasses may need to redefine this.
39 ## <a name="is_MultiValued() - $boolean"></a> isMultiValued() -> $boolean
41 Is the field type multi-valued (i.e. does it store multiple values)? Subclasses may need to redefine this.
43 ## <a name="is_TextMergeable() - $boolean"></a> isTextMergeable() -> $boolean
45 Is this field type mergeable using a conventional text merge?
47 ## <a name="isMandatory() - $boolean"></a> isMandatory() -> $boolean
49 Is this field mandatory (required)?
51 ## <a name="render_ForEdit( $web, $topic, $v"></a> renderForEdit( $web, $topic, $value ) -> ($col0html, $col1html)
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.
55 ## <a name="cssClasses(@classes) - $classes"></a> cssClasses(@classes) -> $classes
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.
59 ## <a name="get_DefaultValue() - $value"></a> getDefaultValue() -> $value
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.
63 Some subclasses may not support the definition of defaults in the form definition. In that case this method should return `undef`.
65 ## <a name="renderHidden($meta) - $html"></a> renderHidden($meta) -> $html
67 Render the form in `$meta` as a set of hidden fields.
69 ## <a name="populate_MetaDataFromQuery( $que"></a> populateMetaDataFromQuery( $query, $meta, $old ) -> ($bValid, $bPresent)
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.
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)
75 ## <a name="ObjectMethod <strong>render_ForDisplay*"></a> [[ObjectMethod]] \*renderForDisplay `($format,$attrs) -> $html`
77 Render the field for display, under the control of $attrs.
79 The following vars in $format are expanded: $title - title of the form field $value - expanded to the **protected** value of the form field
81 The value is protected by TWiki::Render::protectFormFieldValue.