field

Creates a text area where users can display and enter one or more lines of data.

The field's characteristics determine the number of lines, the width of each line, and whether the field is scrollable.

Field data can be protected from modification, made to display in the system password format (typically, hidden from view), and forced to conform to data type and formatting specifications.

Available options

acclabel, active, bgcolor, border, borderinfo, focused, fontcolor, fontinfo, format, help, itemlocation, itemnext, itemprevious, justify, keypress, label, labelbgcolor, labelborder, labelfontcolor, labelfontinfo, mouseover, next, previous, printbgcolor, printlabelbgcolor, printfontcolor, printlabelfontcolor, printvisible, readonly, rtf, scrollvert, scrollhoriz, size, suppresslabel, texttype, value, visible, writeonly, xformsenabled, xformsreadonly, xformsrequired, xformsvalid, xforms:input, xforms:secret, xforms:textarea

Example

This is an example of a single line field item that allows entry of a numeric value (e.g. 10000). It formats the value according to locale-specific currency rules (e.g. $10,000.00), and stores the raw numeric value in the XForms data layer (e.g. 10000). The field provides a hint message to guide user input, and it also provides an alert message with immediate feedback if the user enters a value that violates the given XForms constraint (e.g. 1,000,000).

   ...
   <xforms:instance xmlns="" id="loan">
      <LoanRecord>
         <Principal>10000</Principal>
         ...
      </LoanRecord>
   </xforms:instance>
   ...
   <xforms:bind nodeset="Principal" constraint=". >= 1000 and . &lt;= 100000"/>
   ...
   <field sid="PrincipalItem">
      <xforms:input ref="Principal">
         <xforms:label>Principal of Loan:</xforms:label>
         <xforms:hint>Enter the amount of money you will give the borrower.</xforms:hint>
         <xforms:alert>The dollar value must be between 1000 and 100000</xforms:alert>
      </xforms:input>
      <format>
         <datatype>currency</datatype>
      </format>
   </field>

This is an example of a single line field item that allows 20 characters of input. An initial value of 23000 has been defined for the field. When the form appears, the field will contain this value.

   <field sid="income_field">
      <label>Annual income</label>
      <value>23000</value>
      <size>
         <width>20</width>
         <height>1</height>
      </size>
      <fontinfo>
         <fontname>Courier</fontname>
         <size>12</size>
         <effect>plain</effect>
      </fontinfo>
      <labelfontinfo>
         <fontname>Helvetica</fontname>
         <size>12</size>
         <effect>plain</effect>
      </labelfontinfo>
      <labelfontcolor>blue</labelfontcolor>
   </field>

Usage details

  1. Use of the non-XForms version of this item is deprecated because it does not work when placed in a pane or table. Form authors are encouraged to use this item with its XForms element even when not placed in a pane or table in order to maximize form maintainability.
  2. When setting the size option of a field, the width of the field will be based on the average character size for the font in use (set with the fontinfo option) and the height will exclude the external font leading.
  3. Use the readonly option to create a readonly field.
  4. Use the writeonly option to create a write only field. This is useful for passwords.
  5. The format option specifies the data type of the field's data. It also contains flags that allow the application of specified edit checks and formatting to the data.
  6. The label option defines the field's label. The label is placed above the field and aligned with the field's left edge.
  7. The scrollvert and scrollhoriz options govern a field's scrolling characteristics. They must be set to always to permit scrolling. With scrolling enabled, scroll bars display along the bottom (horizontal scrolling) and right (vertical scrolling) edges of the field.
  8. The texttype option determines whether a field contains plain text or rich text. Note that you cannot dynamically change a rich text field into a plain text field.
  9. When using XForms, the following rules apply:
    • To create a single line field, use xforms:input.
    • To create a multi-line field, use xforms:textarea.
    • To create a rich text field, use xforms:textarea. In this case, it is the rtf option that is bound to the data model (as opposed to the value option). Rich text fields do not support the use of xforms:input or xforms:secret.
    • To create a write only field, use xforms:secret.