# Change data schema dynamically

**URL:** <https://jsonforms.discourse.group/t/change-data-schema-dynamically/765>\
**Category:** General\
**Created:** [May 17, 2022, 10:27am UTC](https://jsonforms.discourse.group/t/change-data-schema-dynamically/765 "2022-05-17T10:27:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![OndrejPontes](https://yyz2.discourse-cdn.com/free1/user_avatar/jsonforms.discourse.group/ondrejpontes/32/328_2.png) [@OndrejPontes](https://jsonforms.discourse.group/u/OndrejPontes)\
**Post date:** [May 17, 2022, 10:27am UTC](https://jsonforms.discourse.group/t/change-data-schema-dynamically/765/1 "2022-05-17T10:27:56Z")

</div>

Hello there,

I would like to know if it this functionality exists or if there is intention to add this functionality in future and if not, what are reasons to not to do that.

**Functionality:** (React, Material)  
Let’s use this schema for our data:

```auto
const schema = {
  type: 'object',
  properties: {
    flag: {
      type: 'boolean',
    },
    myEnum: {
      type: 'string',
      enum: ['none','1', '2'],
      default: 'none',
    },
  },
  anyOf: [
    {
      if: {
        properties: {
          flag: {
            const: true
          }
        }
      },
      then: {
        properties: {
          myEnum: {
            type: 'string',
            enum: ['none', '1', '2', '3'],
            default: 'none',
          },
        }
      }
    },
  ]
};

```

UI schema is not important in this case, just casual view.

Based on this schema by default, as a user I would like to choose from dropdown one of myEnum values [‘none’,‘1’, ‘2’].  
Later on, when I change flag value to true, I would like to be able to choose from myEnum values [‘none’,‘1’, ‘2’, ‘3’].  
Later on, when I change flag value to false, I would like to be able to choose only from myEnum values [none, 1, 2] and my selected value would be default again.

Thank you.

---

<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:** [May 18, 2022, 10:28am UTC](https://jsonforms.discourse.group/t/change-data-schema-dynamically/765/2 "2022-05-18T10:28:26Z")

</div>

Hi @OndrejPontes,

At the moment we don’t support `if/then` except for validating use cases, e.g. setting `maximum` values. The reason for this is that JSON Schema is very flexible here and supporting this feature generically is a lot of work.

However JSON Forms is very flexible, so you can easily add a custom enum renderer which is able to look into `if/then` as you specify them in your schema and behaves like you outlined.
