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

**URL:** <https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755>\
**Category:** General\
**Created:** [August 12, 2025, 1:04pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755 "2025-08-12T13:04:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kotesh-arya](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/kotesh-arya/32/1305_2.png) [@kotesh-arya](https://jsonforms.discourse.group/u/kotesh-arya)\
**Post date:** [August 12, 2025, 1:04pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755/1 "2025-08-12T13:04:28Z")

</div>

```javascript

{
  "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”,

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 12, 2025, 1:50pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755/2 "2025-08-12T13:50:19Z")

</div>

Hi @kotesh-arya,

Did you enable default support? See [here](https://jsonforms.io/faq/#how-can-i-use-default-values-within-json-forms) for the documentation.

---

<div class="post-metadata">

**Author:** ![kotesh-arya](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/kotesh-arya/32/1305_2.png) [@kotesh-arya](https://jsonforms.discourse.group/u/kotesh-arya)\
**Post date:** [August 12, 2025, 3:14pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755/3 "2025-08-12T15:14:19Z")

</div>

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

 ![image](https://global.discourse-cdn.com/free1/uploads/jsonforms/original/2X/d/dedc7b628d85f05dd2777dab2d244186c3fd6ff0.png)

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 12, 2025, 3:40pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755/4 "2025-08-12T15:40:52Z")

</div>

Hi @kotesh-arya,

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

---

<div class="post-metadata">

**Author:** ![kotesh-arya](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/kotesh-arya/32/1305_2.png) [@kotesh-arya](https://jsonforms.discourse.group/u/kotesh-arya)\
**Post date:** [August 12, 2025, 3:47pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755/5 "2025-08-12T15:47:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sdirix](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/sdirix/32/1073_2.png) [@sdirix](https://jsonforms.discourse.group/u/sdirix)\
**Post date:** [August 12, 2025, 4:02pm UTC](https://jsonforms.discourse.group/t/setting-default-values-for-a-boolean-field-in-jsonform-is-not-working-as-expected/2755/6 "2025-08-12T16:02:46Z")

</div>

Hi @kotesh-arya,

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

```auto
{
  "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"]
        }
      }
    }
  }
}

```
