Form fields

Form fields are form elements designed for data input and/or data display.

Purpose of form fields

A form field is a form item dedicated to data management. It associates a form item with a screen record field. The screen record field will be used to bind program variables in interaction instructions (i.e. dialogs). The program variables will be the data models for the form fields.

There are different sort for form fields:

Form fields can be used in a grid-based layout or in a stack-based layout.

Form fields are identified by the field name in programs, and are grouped in screen records (or screen arrays in case of list containers). The interactive instruction must mediate between screen record fields and database columns by using program variables.

Form fields are usually related to database column, which types are defined in the database schema file.

Forms fields in grid-based containers

In a grid-based container, the position and size of a form field is defined with an item tag in the form layout, while the rendering and behavior is defined in the ATTRIBUTES section. Both parts are bound by the name of the item tag. The item tag name is local to the .per file and is not available at runtime: It is just the key to bind the item tag (position) with the item definition (attributes).

In the next example, the "f1" item tag (in the LAYOUT section) is linked to the "vehicle.num" form field definition (in the ATTRIBUTES section), which references a column of the "vehicle" table, defined in the "carstore" database schema:

SCHEMA carstore 
LAYOUT
GRID
{
Number:   [f1            ]
Name:     [f2                        ]
}
END
END
TABLES
  vehicle 
END
ATTRIBUTES
  EDIT f1 = vehicle.num, STYLE="keycol";
  EDIT f2 = vehicle.name, UPSHIFT;
END

Forms fields in stack-based containers

In a stack-based container, the visual position of a form field is defined by the ordinal position of the stack item in the stack definition, while the rendering and behavior are defined with stack item attributes.

In the next example, the "vehicle.num" form field definition references a column of the "vehicle" table, defined in the "carstore" database schema:

SCHEMA carstore 
LAYOUT
  STACK
  GROUP
    EDIT vehicle.num, REQUIRED, STYLE="keycol";
  END
  END
END
TABLES
  vehicle 
END