4D v17.4Form |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v17.4
Form
|
Form -> Function result | ||||||||
Parameter | Type | Description | ||||||
Function result | Object |
![]() |
Form data associated to the current form | |||||
The Form command returns the object associated with the current form, if any. 4D automatically associates an object to the current form in the following cases:
If the current form is being displayed by a call to the DIALOG command, Form returns either an empty object, or the formData object passed as parameter to this command, if any.
If the current form is a subform, the returned object depends on the parent container variable:
For more information, please refer to the Page subforms section.
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 variables:
Here is the code for the "Check children" button:
C_LONGINT($win;$n;$i)
C_BOOLEAN($save)
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
Note: This example requires that object notation be enabled in the database (see Compatibility page).
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).
Product: 4D
Theme: Forms
Number:
1466
Created: 4D v16 R5
4D Language Reference ( 4D v17.4)