JSON Schema Form setting default values not working

I tried setting default value in properties of schema definition. However it does not work. Also tried setting value and placeholder attribute.

Hey @nemanjamilosevic99! Would you mind sharing your current JSON Schema value? Also, what default values would you like to set?

I'm having this issue as well. My json form populates as expected aside from the default value for a single property. Any thoughts on what is causing the issue?

{
    "title": "Add New Config",
    "type": "object",
    "required": [
        "created_by"
    ],
    "properties": {
        "created_by": {
            "type": "string",
            "title": "created_by",
            "readOnly": true,
            "default": "user@domain.com"
        }
    }
}

Hey @edwinison, I know we chatted and resolved your issue, but I just wanted to post here for others that might find the solution useful. Tagging the OP @nemanjamilosevic99 as well for visibility. Hope this is helpful!

The JSON Form component takes three different Javascript objects as inputs. One of these is the JSON Schema input which specifics properties of the form. Another is labeled Default Form Data and accepts an object with keys that match keys in the properties object in the JSON Schema object .

There's a good example in the default values supplied in the JSON Schema Form component when you first drop it on the canvas (screenshot attached below). You can see that the default JSON Schema includes a properties object with three keys:

{
  ...
  "properties": {
      "username": {
        "type": "string",
        "title": "Username"
      },
      "password": {
        "type": "string",
        "title": "Password",
        "minLength": 3
      },
      "birthday": {
        "type": "string",
        "title": "Birthday",
      }
    }
  ...
}

And the default values for these three fields are supplied as keys in the Default Form Data input:

{
  "username": "john.doe",
  "password": "johndoeisthebest",
  "birthday": "1970-01-15"
}

1 Like

Thanks, Alex! Yes that was exactly what I was missing and your assistance unblocked me immediately. Thanks again. Good luck, OP!