Setting default values for a boolean field in jsonform is not working as expected


{
  "batteries_required": {
    "title": "Are batteries required?",
    "description": "Select \"yes\" if batteries are required to power the item (or if the item is a battery) or no if they are not. Please note that an internal rechargeable battery is also considered a battery",
    "type": "array",
    "minItems": 1,
    "maxUniqueItems": 1,
    "minUniqueItems": 1,
    "selectors": ["marketplace_id"],
    "items": {
      "type": "object",
      "additionalProperties": false,
      "required": ["value"],
      "properties": {
        "marketplace_id": {
          "type": "string",
          "default": "A39IBJ37TRP1C6",
          "hidden": true
        },
        "value": {
          "type": "boolean",
          "title": "Are batteries required?",
          "description": "Select \"yes\" if batteries are required to power the item (or if the item is a battery) or \"no\" if they are not. Please note that an internal rechargeable battery is also considered a battery",
          "editable": true,
          "hidden": false,
          "default": false,
          "enum": [false, true],
          "enumNames": ["No", "Yes"],
          "examples": ["Yes"]
        }
      }
    }
  }
}

Passing this schema:

Do let me know if any other information is needed:

@jsonforms/core”: “3.5.1”,

@jsonforms/material-renderers”: “3.5.1”,

@jsonforms/react”: “3.5.1”,

Hi @kotesh-arya,

Did you enable default support? See here for the documentation.

I have done the suggested changes as per the resource, but Still cannot see the boolean checkbox checked.

Hi @kotesh-arya,

You need defaults on all levels, then it should work.

I didn’t get you
Could you please expand on this ?

Hi @kotesh-arya,

You should also define a default for batteries_required and for the items object, i.e.

{
  "batteries_required": {
    "default": [],
    "title": "Are batteries required?",
    "description": "Select \"yes\" if batteries are required to power the item (or if the item is a battery) or no if they are not. Please note that an internal rechargeable battery is also considered a battery",
    "type": "array",
    "minItems": 1,
    "maxUniqueItems": 1,
    "minUniqueItems": 1,
    "selectors": ["marketplace_id"],
    "items": {
      "default": {},
      "type": "object",
      "additionalProperties": false,
      "required": ["value"],
      "properties": {
        "marketplace_id": {
          "type": "string",
          "default": "A39IBJ37TRP1C6",
          "hidden": true
        },
        "value": {
          "type": "boolean",
          "title": "Are batteries required?",
          "description": "Select \"yes\" if batteries are required to power the item (or if the item is a battery) or \"no\" if they are not. Please note that an internal rechargeable battery is also considered a battery",
          "editable": true,
          "hidden": false,
          "default": false,
          "enum": [false, true],
          "enumNames": ["No", "Yes"],
          "examples": ["Yes"]
        }
      }
    }
  }
}