4D v13.4

Using inherited forms

Home

 
4D v13.4
Using inherited forms

Using inherited forms  


 

 

4D lets you use “inherited forms.” The means that you are able to use all the objects from Form A in a Form B: Form B thus “inherits” the objects from Form A. 

Suppose, for example, that all entry forms belonging to a database have to contain the OK, Cancel, Next, and Previous buttons as well as a logo. Simply create a form containing only these elements and then call it as an inherited form in all database entry forms. Each entry form contains only fields and objects specific to its use.

Unlike form templates set using the Form Wizard (see Creating a form template), the reference to the inherited form is always active: if an element of the inherited form is modified (button styles, for example), all forms using this element will automatically be modified.

Both table and project forms can use (or be used as) inherited forms.

Once using the database, inherited form objects are dynamically combined with those of the open form. This mechanism is very similar to that of the “page 0” form mechanisms, the difference being that it can be applied to all of the database forms as a whole. 

When the form is executed, the objects are loaded and combined in the following order:

  1. Page zero of the inherited form
  2. Page 1 of the inherited form
  3. Page zero of the open form
  4. Current page of the open form.

This order determines the entry order of objects in the form.

Note: Only pages 0 and 1 of the inherited form can appear in other forms. 

The properties (window name, re-sizing, events, etc.) and the method of an inherited form are not considered when used as an inherited form. On the other hand, the methods of objects that it contains are called.

Form inheritance starts in the 4D Form editor. 

To define an inherited form:

  1. In the Form editor, open the form where you want to inherit something from another form.
  2. Display the Property List and click outside all objects in the form in order to see form properties.
    The “Inherited Form Table” and “Inherited Form Name” lists are available. All database tables and their forms are displayed.
  3. Select the table and then the form name to inherit. To inherit from a project form, select <None> in the "Inherited Form Table" list.

All forms can be designated as inherited form. However, the elements they contain must be compatible with use in different database tables.

Once an inherited form is selected, its contents appear in the current edit window. This is only a preview; it is not possible to select or modify an object in this form. To do that, you should open it in its own window.

You can hide the objects of an inherited form by deselecting the Inherited form option in the Display submenu of the Form menu or in the editor’s context menu. 

To stop inheriting a form, select the <None> option in the Property List.

Note: It is possible to define an inherited form in a form that will eventually be used as an inherited form for a third form. The combining of objects takes place in a recursive manner. 4D detects recursive loops (for example, if form [table1]form1 is defined as the inherited form of [table1]form1, in other words, itself) and interrupts the form chain.

 
PROPERTIES 

Product: 4D
Theme: Building forms