This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Form

Form 


 

Form -> Function result 
Parameter Type   Description
Function result  Object in 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:

  • the current form has been displayed by the DIALOG command,
  • the current form is a subform,
  • a table form is currently displayed on screen.

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. 

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 (_O_C_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:
  • 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.

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 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).



See also 

DIALOG

 
PROPERTIES 

Product: 4D
Theme: Forms
Number: 1466

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v16 R5

 
ARTICLE USAGE

4D Language Reference ( 4D v20 R7)