Form Concepts
This page explains the concepts 4HSE forms are built on. To add logic to a form with JavaScript see Coding Forms; to use the tools a form is built with see Simple Form Editor and Advanced Form Editor. For the user guide see Forms.
What is a form
Section titled “What is a form”A form is a document that people fill in on screen: a register, a checklist, a report to compile. A form is a JSON file with the .hf extension, built with one of the two editors. The difference between a form and a filled-in form is in the user guide: Forms.
The parts of a form
Section titled “The parts of a form”A form is made of four parts: metadata, widgets, widget id and name, and script.
Metadata
Section titled “Metadata”The metadata tell when and where the form is offered:
| Metadata | What it says |
|---|---|
| Name and description | how the form presents itself when it is chosen |
| Tags | labels to filter the list of forms |
| Launch points | the places in the app the form is offered from |
| Country and language | for people working in which country and language the form is offered |
Launch points are the same as for reports: see Launch points. A form with no launch points is never offered: it can only be opened from the file system. See Launch points decide where a form appears. Country and language are permissive filters, as in reports: if empty, the form is valid in every country and every language. See Country and language.
Widgets
Section titled “Widgets”A form is made of widgets: rows and columns that arrange the contents, texts, and input fields (text boxes, dropdowns, checkboxes, dates, signatures). There are also ready-made blocks of 4HSE, such as the header with the logo or the attendance register. The field types of the simple editor are described in Simple Form Editor.
Widget id and name
Section titled “Widget id and name”Every widget has an id (its identifier in the form, unique) and, if it is a field, a name. The script finds a widget by its id, and the name of the event handlers comes from it. For this reason the id contains only letters, numbers and underscores, and does not start with a number.
Script
Section titled “Script”The script gives the form its behaviour: it fills in fields when the form opens, shows or hides a group of fields according to an answer, loads data from 4HSE. It is a set of JavaScript functions, attached to the widgets by their name (onInit, <id>OnChange…). How to write it is explained in Coding Forms.
The two editors
Section titled “The two editors”A form is built with one of two editors:
| Simple editor | Advanced editor | |
|---|---|---|
| Structure | a list of fields, one below the other | components placed freely, also side by side, with rows, columns and tables |
| Available fields | 7 types: checkbox, text, text area, dropdown, single choice, multiple choice, signature | every component, with every property configurable |
| Preview and undo | no | yes |
| When to use it | a simple checklist or register | a document with a particular layout |
A form opens again in the editor it was created with. See Simple Form Editor and Advanced Form Editor.
How a form runs
Section titled “How a form runs”When a person opens a form, 4HSE runs these steps, in order:
- The widgets are built, and the form appears on screen.
- The functions of the script are attached to the widgets according to their name.
onInitruns: it can already change the widgets.- The person fills in the form. When a widget triggers an event (for example a change of value), the function attached to that event runs.
An error in a function does not stop the form: it is written in the console of the browser.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.