# Help with default values

**URL:** <https://jsonforms.discourse.group/t/help-with-default-values/31>\
**Category:** General\
**Created:** [April 9, 2020, 6:37pm UTC](https://jsonforms.discourse.group/t/help-with-default-values/31 "2020-04-09T18:37:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![discobot](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/discobot/32/3_2.png) [@discobot](https://jsonforms.discourse.group/u/discobot)\
**Post date:** [April 9, 2020, 6:37pm UTC](https://jsonforms.discourse.group/t/help-with-default-values/31/1 "2020-04-09T18:37:09Z")

</div>

Hello!

I’m on 2.3.2 and can’t seem to get default values to appear. I notice that there are default values set in schema in this example but it is unused [Layout Example - JSON Forms](https://jsonforms.io/examples/layouts).

Upon loading, I’m met with empty fields that are not populated with default values,

Here is part of my schema written in yaml.

```auto
        nationality:
          default: US
          enum:
          - DE
          - IT
          - INDO
          - JP
          - US
          - RU
          type: string
        number_field:
          default: 6
          maximum: 10
          minimum: 5
          type: number
        rico_field:
          type: string
        since_sync:
          type: string
        test_field:
          default: default value
          type: string

```

And my component

```auto
        <JsonForms
            data={data}
            schema={schema}
            uischema={uischema}
            renderers={materialRenderers}
            cells={materialCells}
            onChange={({ errors, data }) => {console.log(data); updateData(errors, data)}}
        />

```

_[[original thread](https://spectrum.chat/jsonforms/general/help-with-default-values~04e3450f-1c96-4a0b-a5aa-6bb662ad861e) by Ricardo Guntur]_

---

<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:** [April 15, 2020, 6:47am UTC](https://jsonforms.discourse.group/t/help-with-default-values/31/2 "2020-04-15T06:47:27Z")

</div>

Hi @ricardo-guntur, we let Ajv handle the default values. As we require certain Ajv settings you can use the exported Ajv factory `createAjv(options)` and set `useDefaults: true`. The customized Ajv can then be passed into the JsonForms component, e.g.

```auto
const handleDefaultsAjv = createAjv({useDefaults: true});
// [...]
        <JsonForms
            data={data}
            schema={schema}
            uischema={uischema}
            renderers={materialRenderers}
            cells={materialCells}
            onChange={({ errors, data }) => {console.log(data); updateData(errors, data)}}
            ajv={handleDefaultsAjv}
        />

```
