- Merged #224: Added a multiple checkboxes widget.
Multiple choices list
The default behavior for array fields is a list of text inputs with add/remove buttons. Though there are two alternative simpler widgets for common situations like picking elements against a list of choices; typically this maps to a schema having:
- an
enum
list for theitems
property of anarray
field - with the
uniqueItems
property set totrue
Example:
const schema = {
type: "array",
title: "A multiple choices list",
items: {
type: "string",
enum: ["foo", "bar", "fuzz", "qux"],
},
uniqueItems: true
};
By default, this will automatically render a multiple select box. If you prefer a list of checkboxes, just set the uiSchema ui:widget
directive to "checkboxes"
for that field:
const uiSchema = {
"ui:widget": "checkboxes"
};
See the "Arrays" section of the playground for cool demos.