Skip to main content
Version: 2.4

Data - Forms

In many situations, you will want to set up forms to create or edit instances of custom data types. DRAW provides you with a helper to easily create forms.

Generate a form

Create a new custom data type, e.g. Customer with some properties.

Data type

To generate a form for this component, open the menu and click on Generate helper bricks and forms.

Generate helpers

Under the Form column of the popup, select the properties for which you want to generate a field.

Select form properties

The generator creates one field per property depending on its type.

Sample form

By default, a form is generated with one property Edited Object and three events Save, On Saved, and On Error.

Sample form spec

Use a form

In a screen or in a visual component, you can then find the newly created form in the marketplace on the right. The form has two behaviors:

If Edited Object is not set, the form is initially empty. Triggering the Save event then creates a new object with its properties set to the values currently entered in the form. That new object is then stored in Edited Object, such that you can retrieve it easily.

If Edited Object is set, then the properties of the new object are loaded in the form. Triggering the Save event then updates the object with the values currently entered in the form.

In case you want to trigger further actions upon save, the form also exposed two other events which are triggered upon save:

  • If successful, On Saved is called.
  • If some error occurs, On Error is called.

Those behave like the On Click of a button for example, and you can define your own behavior within the f(x).

Here is a schema representing that logic:

Save logic

Modify a form

The form is automatically generated as a new brick in DRAW. That means that you can easily open it and modify it, in case you want to change its behavior. One typical example is if you need to add or remove some fields in the form, or which to change its appearance.

Similarly, the Edited Object behavior described above (create if not set, modify if set) is predefined in the generated form's Save event. You may have to change that function, in case you add or remove fields within the form, or if you want to change its behavior. If you open the form, you can see there that the Save event is already defined. Click on f(x) button to edit it.

Form save event