Presenting forms to users and handling the response is a common task in a web application. The Haplo Platform helps speed up development of HTML forms, using a declarative approach to describing a form, and a streamlined API for handling the responses.
As a bonus, it can also generate a static HTML display of the data in the document from the same form specification, often eliminating the need to write custom templates for displaying data manipulated by this system.
Forms can be automatically translated to the user’s current locale when you include translated strings resources in your plugin.
The forms system uses several components. It’s worth being aware of them, but when you’re using the forms system in a request handler, it all pretty much takes care of itself.
The specification is a JSON document describing the form.
The form is split into sections, which group fields, and form elements, which describe the fields themselves. Sections can be repeating, which allows the user to enter a table of data, adding rows as required.
Form specifications are conventionally stored as JSON files within your plugin’s
The document is a JSON compatible data structure which holds the data being filled in or edited by the user.
The forms system takes great care to maintain all the data in the document which isn’t mentioned in the specification. You can store extra data in a document, or define multiple forms for the same document, without fear data will be removed.
The description is a
FormDescription object which is generated from a specification.
A form is made up of one or more form elements. These largely correspond to HTML elements, such as
Each form element is specified in the specification, including where the data comes from in the document and the validation rules.
Once you’ve got a description, you create an instance to generate the HTML form for a given document and handle the response. This is a
FormInstance object created by the description.
Some of the form elements require that the user picks an item from a list. A data source describes these lists, for example, allowing the user to pick a
StoreObject from all objects of a given type.