jsonforms icon indicating copy to clipboard operation
jsonforms copied to clipboard

Making forms of array items readonly

Open Janekk opened this issue 3 years ago • 1 comments

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

  1. Go to my fork of jsonforms-react-seed
  2. Notice readOnly flags I added on the schema
  3. Run the project
  4. 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

Janekk avatar Jul 05 '22 10:07 Janekk

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:

Janekk avatar Jul 05 '22 10:07 Janekk