jsonforms
jsonforms copied to clipboard
Making forms of array items readonly
Describe the bug
Hi,
My schema contains a field that is an array of objects and I want to make these objects readonly. I tried setting the readOnly flag on a few levels but the sub-forms for array items still render as editable.
Notice readOnly flags I added on the schema
Expected behavior
Setting "readOnly": true on items object (or its parent?) should make the children read only.
"payment": {
"type": "object",
"properties": {
"paid": { "type": "boolean" },
"charges": {
"type": "array",
"readOnly": true,
"items": {
"readOnly": true,
"properties": {
"amount": { "readOnly": true, "type": "number" },
"dispute": { "readOnly": true, "type": [ "boolean", "null" ] }
}
}
}
}
}
Steps to reproduce the issue
- Go to my fork of jsonforms-react-seed
- Notice readOnly flags I added on the schema
- Run the project
- See the array item inputs are not read only
Screenshots
No response
In which browser are you experiencing the issue?
Google Chrome 103.0.5060.53 (Official Build) (64-bit)
Framework
React
RendererSet
Material
Additional context
No response
setting readOnly on individual properties worked:
"payment": {
"type": "object",
"readOnly": true,
"properties": {
"paid": { "type": "boolean" },
"charges": {
"type": "array",
"readOnly": true,
"items": {
"readOnly": true,
"properties": {
"amount": { "readOnly": true, "type": "number" },
"dispute": { "readOnly": true, "type": [ "boolean", "null" ] }
}
}
}
}
} "payment": {
"type": "object",
"readOnly": true,
"properties": {
"paid": { "type": "boolean" },
"charges": {
"type": "array",
"readOnly": true,
"items": {
"readOnly": true,
"properties": {
"amount": { "readOnly": true, "type": "number" },
"dispute": { "readOnly": true, "type": [ "boolean", "null" ] }
}
}
}
}
} "payment": {
"type": "object",
"readOnly": true,
"properties": {
"paid": { "type": "boolean" },
"charges": {
"type": "array",
"readOnly": true,
"items": {
"readOnly": true,
"properties": {
"amount": { "readOnly": true, "type": "number" },
"dispute": { "readOnly": true, "type": [ "boolean", "null" ] }
}
}
}
}
}
but one would expect it would work when we set it the parent object, like it is for payment :thinking: