JSON Forms allows to enable and disable any input, either programmatically, via JSON Schema or the UI schema.
The whole form can be disabled by specifying the readonly
flag on the JsonForms
component itself.This will disable all elements of this form.
This flag is also supported by the Angular and Vue bindings.
{
type: "VerticalLayout",
elements: [
{
type: "Control",
scope: "#/properties/firstName",
options: {
readonly: true
}
}
]
}
Any UI schema element can be enabled or disabled dynamically via our rule support.
{
type: "VerticalLayout",
elements: [
{
type: "Control",
scope: "#/properties/firstName",
rule: {
effect: "DISABLE",
condition: {
scope: "#",
schema: {} //always true
}
}
},
// OR
{
type: "Control",
scope: "#/properties/firstName",
rule: {
effect: "ENABLE",
condition: {
scope: "#",
schema: { not: {} } //always false
}
}
}
]
}
JSON Forms determines the enabled
status for each UI schema element based on the following order