Creating notice forms

So that your users can create and publish their notices, your application needs to show them the right notice form to fill in.

The form should be organised in a way that helps users to understand the steps of creating a notice and, above all, the information that they should give in each field.

The form should also show clear messages, so that users can correct their mistakes one by one, until their notice is ready to be submitted for publication.

This is not a simple task. The Publications Office shares in the eForms SDK the notice type definitions that it uses in its own form-filling application, eNotices2, so that developers can reuse and extend this work.

This page presents a solution for applications driven by metadata, which use the eForms SDK. If you are developing a traditional application, you can still use the solution presented here as an example.
What is a notice type definition file?

A notice type definition (NTD, as the Publications Office calls them internally) is a text file, in JSON format. It gives the visual structure of a notice form, as it should appear on the screen of a user. The eForms SDK contains one such file for every notice subtype that users can create.

Selecting the right form

To select the form for the type of notice that your user wants to create, you need to show the user all the possible choices. You find the metadata that you need to show these choices in notice-types/notice-types.json in the eForms SDK.

The choices available to the user depend on the version of the eForms SDK that you use. Your application finds them while it runs, by reading the metadata in notice-types.json.

When the user has selected the type of notice that they want to create, you need to show them a form, so that they can fill in their notice.

Putting the form on the screen

The aim is to create the form from the metadata, instead of programming it by hand. Your program needs to do the following:

  1. Open the notice type definition file of the notice subtype that the user selected. If, for example, the user selected the notice subtype 12, open notice-types/12.json.

    Inside that notice type definition file, your program finds a hierarchy of display items. Each of them stands for an item that you need to place on the screen of the user. These items are either display-groups or input-fields. The input-fields are the active items on the screen, in which the user enters the data. The display-groups give the form its visual structure.
  2. Go through the hierarchy of display items in the notice type definition. For each of them, create a visual item on the screen of the user: a visual container for each display-group, and an input control for each input-field.

    As you create these items on the screen, use the metadata attached to each item to decide how it looks and works. Some items, for example, are marked as repeatable. For these, you need to give your users a way to add more than one of them to the form.

After you have gone through the hierarchy once, you have a form that your user can fill in. For a detailed description of the metadata in notice type definition files, see Notice Types.

You can do this each time that your user selects a notice subtype. You can also convert all notice type definitions once, into a format that suits your application better, as soon as you add a new version of the eForms SDK to your application.