This project is not being actively developed or maintained.
Try a Demo | Watch the Video |
This module contains the forms plugin from hawtio. The hawtio-forms module provides an easy way, given a JSON Schema-like model of generating a form with 2 way binding to some JSON data.
hawtio-forms currently contains two implementations that draw forms, forms and forms2. Currently the forms2 plugin is quite usable, supports more types and styles and is the recommended plugin to use for forms going forward. The old forms plugin will stick around for awhile for backwards compatability.
See a demo in action at forms.hawt.io
You can also have a look at the forms2 interfaces and the forms interfaces
yarn add @hawtio/forms
git clone https://github.com/hawtio/hawtio-forms
cd hawtio-forms
yarn install
yarn start
The easiest way to customise the generated form is to specify which order you want the fields to appear; or to move different fields onto different tabs using the tabs object on a json schema type. e.g.
tabs: {
'Tab One': ['key', 'value'],
'Tab Two': ['*'],
'Tab Three': ['booleanArg'],
'Tab Four': ['foo\\..*']
}
You can use "*" to refer to all the other properties not explicitly configured.
In addition you can use regular expressions to bind properties to a particular tab (e.g. so we match foo.* nested properties to Tab Four above).
You can add a hidden flag on a property in a JSON schema to hide it from the auto-generated forms. Or you can set its type to be hidden.
e.g.
properties: {
foo: {
type: "string",
label: "My Foo Thingy"
},
bar: {
type: "string",
hidden: true
}
}
in the above, the bar property will be hidden from the generated form
If you wish to specify a custom label for a property (as by default it will just humanize the id of the property), you can just specify the 'label' property inside the JSON Schema as follows:
properties: {
foo: {
type: "string",
label: "My Foo Thingy",
tooltip: "My tool tip thingy"
}
}
The label and tooltip properties are not part of JSON Schema; but an extension like the tabs property above.
If your schema doesn't have actual labels the default behaviour is to take the property keys and to humanize them; to turn camelCaseWords into "Camel case words" and so forth.
However if you wish to preserve exactly the keys/ids of the model on the form, you can specify the disableHumanizeLabel flag on the schema...
schema: {
disableHumanizeLabel: true
properties: {
foo: {
type: "string",
}
}
}