Skip to main content
Version: Next

Form

Form : Object

ParameterTypeDescription
Function resultObjectForm data of the current form
History
ReleaseChanges
20 R8Form class support

Description

The Form command returns the object associated with the current form (instantiated from the formData parameter or the user class assigned in the Form editor). 4D automatically associates an object to the current form in the following cases:

  • the current form has been loaded by one of the DIALOG, Print form, or FORM LOAD commands,
  • the current form is a subform,
  • a table form is currently displayed on screen.
Commands (DIALOG...)

If the current form is being displayed or loaded by a call to the DIALOG, Print form, or FORM LOAD commands, Form returns either:

Subform

If the current form is a subform, the returned object depends on the parent container variable:

  • If the variable associated to the parent container has been typed as an object, Form returns the value of this variable.
    In this case, the object returned by Form is the same as the one returned by the following expression:
 (OBJECT Get pointer(Object subform container))->  
  • If the variable associated to the parent container has not been typed as an object, Form returns an empty object, maintained by 4D in the subform context.

For more information, please refer to the Page subforms section.

Table form

Form returns the object associated with the table form displayed on screen. In the context of an input form displayed from an output form (i.e. after a double-click on a record), the returned object contains the following property:

PropertyTypeDescription
parentFormobjectForm object of the parent output form

Example

In a form displaying the record of a person, a "Check children" button opens a dialog to verify/modify the names and ages of their children:

Note: The "Children" object field is represented only to show its structure for this example.

In the verification form, you have assigned some Form object properties to inputs:

Here is the code for the "Check children" button:

 var $win;$n;$i : Integer
var $save : Boolean
ARRAY OBJECT($children;0)
OB GET ARRAY([Person]Children;"children";$children) //get the children collection
$save:=False //initialize the save variable

$n:=Size of array($children)
If($n>0)
$win:=Open form window("Edit_Children";Movable form dialog box)
SET WINDOW TITLE("Check children for "+[Person]Name)
For($i;1;$n) //for each child
DIALOG("Edit_Children";$children{$i}) //displays dialog filled with values
If(OK=1) //the user clicked OK
$save:=True
End if
End for
If($save=True)
[Person]Children:=[Person]Children //forces object field update
End if
CLOSE WINDOW($win)
Else
ALERT("No child to check.")
End if

The form displays information for each child:

If values are edited and the OK button is clicked, the field is updated (the parent record must be saved afterwards).

See also

DIALOG

Properties

Command number1466
Thread safe