---
title: "Advanced Form Editor"
url: "https://dev.4hse.com/guides/forms/advanced-form-editor"
description: "Guide to the 4HSE advanced form editor: starting models, components and tree, properties panel, form configuration, the Event Map script, preview, undo and saving."
---

# Advanced Form Editor

The **Advanced editor** builds a [form](/guides/forms/coding-forms/) by placing components in a work area. Fields can be put side by side, arranged in rows, columns and tables, and duplicated, and every property of a component can be set. When the form is a plain list of questions, the [Simple Form Editor](/guides/forms/simple-form-editor/) is quicker.

This page describes what the editor shows and what you can do with it. For the JavaScript that gives a form its behaviour, see [Coding Forms](/guides/forms/coding-forms/).

## Open the editor

[Section titled “Open the editor”](#open-the-editor)

-   **A new form.** In the file manager of an office or project, click the **New** icon and choose **New form (advanced editor)**. Before the editor opens, the **Select model** window asks for a starting point.
-   **An existing form.** In the file manager, select the `.hf` file and click **Modify**, or right-click it and choose **Modify**. A form that was made with the [simple editor](/guides/forms/simple-form-editor/) opens there instead.

Closing the editor with changes not saved asks for confirmation (_Edited document_): going on discards them.

### The starting model

[Section titled “The starting model”](#the-starting-model)

Model

What it starts with

**Empty model**

an empty document

**Vertical form**

a form with stacked fields

**Inline form**

a form with inline fields

**Checklist form**

a form that contains a checklist

The model is only a set of components already placed: once it is open, you can change everything in it.

## The window

[Section titled “The window”](#the-window)

The window has four areas:

-   the **toolbar**, at the top;
-   the **Components** and **Tree** tabs, on the left;
-   the **work area**, in the centre: the form with the tools to edit it;
-   the **properties panel**, on the right: the properties of the selected item.

![A form in the advanced editor: components on the left, the form in the work area, properties on the right](/_astro/advanced-form-editor-window.Cj3MH39x_2bfIoQ.webp)

In the work area the form is shown with the tools to edit it, such as highlights and the icons on the items, so it may look different from the final result: the **Preview** icon shows it as the person filling it in will see it.

### Toolbar

[Section titled “Toolbar”](#toolbar)

Control

What it does

**Save** (floppy disk, with a menu)

**Save** overwrites the file, **Save as** saves it with another name or in another folder. See [Saving](#saving)

**Preview**

shows the form as the person filling it in will see it, in a window of its own

**Undo**, **Redo**

step back and forward through your changes. They are disabled until there is something to undo or redo

**Device size**

the width of the work area and of the preview: **Fit the width**, **A4**, or the width of a phone or a tablet, upright or sideways

## Components and tree

[Section titled “Components and tree”](#components-and-tree)

The left panel has two tabs.

### Components

[Section titled “Components”](#components)

The components you can add, in groups:

Group

Contains

**Input labeled**

a label plus a field, suited to forms with fields stacked one below the other

**Input base**

a field with no label, suited to forms with fields side by side

**Static**

items that are not filled in: titles, labels, text

**Layout**

containers that arrange the other components: see [Layouts and tables](#layouts-and-tables)

**Snippet**

ready-made blocks (_Check list_, _Check list with note_, _Registry_), to insert and adapt

There are two ways to add a component:

-   drag it onto the work area and drop it where it should appear;
-   click it: it is added after the selected item, inside the selected layout or, if nothing is selected, at the end of the form.

In the work area, drag an item to move it, or drag it while holding **CTRL** to duplicate it where you drop it. Two icons appear on the selected item: one duplicates it, the other deletes it.

### Tree

[Section titled “Tree”](#tree)

The **Tree** tab shows the structure of the form: each component is a node, and the components inside a layout are its child nodes. The first node, **Form**, is the form itself and holds its general information.

Selecting a node selects the item in the work area and opens its properties. When components are packed close together, the tree is the reliable way to select the right one.

## Layouts and tables

[Section titled “Layouts and tables”](#layouts-and-tables)

The **Layout** components arrange the other components of a form. There are three, and they can be nested one inside another.

Layout

How it arranges the components

**Flow layout**

next to each other, like the words of a text: when the space runs out, the following ones wrap to a new line. Not every component can be arranged this way: titles and labeled inputs always start on a new line

**Row layout**

on one line, like the flow layout, but controlling how they are distributed: items can be spaced evenly, centred or aligned to the right

**Column layout**

one below the other. Inside a row layout, several column layouts form columns side by side

![A form built with a flow layout: labels and fields follow each other and wrap](/_astro/advanced-form-editor-flow-layout.C2mUfeHv_w8D9G.webp)

![A row layout with four items side by side](/_astro/advanced-form-editor-row-layout.dKYeHL4K_4t6fO.webp)

### A table built from layouts

[Section titled “A table built from layouts”](#a-table-built-from-layouts)

A table is a row layout containing several column layouts, one per column. The properties that make it work:

Property

Effect

**Width** of each column layout

the width of the column, as a percentage

**Height** with its checkbox cleared

the cells stretch to fill the vertical space

**Border** solid, 1px

draws the grid

**Padding** of the row layout set to 0

removes the space between columns

Each row of the table is a row layout: the rows after the first are obtained by duplicating it.

## Properties

[Section titled “Properties”](#properties)

The panel on the right shows the properties of the selected item, grouped in sections, for example **General** and **Input**. Which ones appear depends on the component: text, size, margins, alignment, fonts, the list of options of a dropdown, validation and others.

-   Each property has a checkbox. When it is cleared, the component uses its default value; when it is ticked, it uses the value you entered.
-   The changes appear in the work area at once. Some take effect only after you click outside the field.
-   **Unique ID** is the id of the component in the form. It must be unique: the editor checks that, and nothing else. A script finds the component with `this.getWidget('<Unique ID>')`, and the functions that handle its events are named after it, so use letters, numbers and underscores, and do not start with a number. See [Coding Forms](/guides/forms/coding-forms/).

### Form configuration

[Section titled “Form configuration”](#form-configuration)

Select the **Form** item, the first of the **Tree** tab. If another item is selected, the panel shows the properties of that item.

The **General** section holds the [metadata](/guides/forms/form-concepts/#metadata) of the form. These are the rules of the editor:

Property

Rule

**Name**

**Required.** The form cannot be saved without it

**Description**, **Tag**

Optional

**Launch points**

A form with no launch points is never offered: it can only be opened from the file system

**Country**, **Language**

See [Country and language](https://docs.4hse.com/forms/#country-and-language-filter-the-list) in the user guide

## The script

[Section titled “The script”](#the-script)

The script of the form is written in the **Event Map** field of the **Input** section of the **Form** item. The field opens a code editor. It holds a set of JavaScript functions, named after the widget and the event they handle: `onInit`, `<widgetId>OnChange`, and so on. The language of the script, the events and the API are described in [Coding Forms](/guides/forms/coding-forms/).

Nothing checks that the name of a function matches a widget: a function with a wrong name is not attached, and the console of the browser says so when the form runs. Test the script with **Preview**, with the console of the browser open.

**Example.** In the **Event Map** of the **Form**:

```
function onInit(event) {  const details = this.getWidget('person_details');  if (details) {    details.hidden = true;  }}
```

### Events of a widget

[Section titled “Events of a widget”](#events-of-a-widget)

The properties panel of a widget that can trigger events has an **Events** section, with one entry for each event, named as in the script (`OnChange`). The **…** button opens the code editor, with line numbers and a check of the syntax, on the **Event Map** of the form, with the cursor on the function of that event. If the function does not exist yet, the editor adds an empty one, `function <Unique ID><Event>(event) {}`: for the event `OnChange` of the widget whose **Unique ID** is `is_anonymous`, `is_anonymousOnChange`. When you save, the whole script is written back to the **Event Map**; an entry shows how many lines its function has.

It is the same script: you can write a function in the **Event Map** and find it in the **Events** section of the widget, or the other way round.

## Preview

[Section titled “Preview”](#preview)

Click **Preview** to see the form as the person filling it in will see it. The preview opens in a window with its own **Device size** menu, starting from the width chosen in the editor. The form is built as when it is filled in, so the script runs and the preview is the way to test it. The form is not opened from an item, so `this.runtime.context` may be empty (see [Coding Forms](/guides/forms/coding-forms/#the-api)).

## Saving

[Section titled “Saving”](#saving)

Click **Save** to open the menu:

-   **Save as** opens the file picker. It shows only the folders you can write to, and saves a `.hf` file. After the first save, the editor keeps working on the new file and the undo history starts again.
-   **Save** overwrites the file the editor is working on: the file the form was opened from, or the one chosen with **Save as**. It is not available for a new form that was never saved.

A form that comes from outside the project (the 4HSE catalogue or a partner’s) and was opened from the form wizard cannot be overwritten: **Save** is disabled until you use **Save as** in a folder of the project. The original stays as it was.

A form cannot be saved without a name: the editor says so and does not save.

This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.