Skip to content

Override a value of dynamically shown field #4433

@dejanbelusic

Description

@dejanbelusic

Prerequisites

What theme are you using?

mui

What is your question?

Hello,

Is it possible to override a value of dynamically shown field if a condition is met?

I was trying this example.
I want to have one conditional field and change it's value if another field is checked or not. Is that possible to do inside a schema?

{
  "title": "Conditional Field Example",
  "type": "object",
  "properties": {
    "includeField": {
      "type": "boolean",
      "title": "Include additional field?"
    },
    "additionalField": {
      "type": "string",
      "title": "Additional Field"
    }
  },
  "dependencies": {
    "includeField": {
      "oneOf": [
        {
          "properties": {
            "includeField": {
              "const": true
            },
            "additionalField": {
              "type": "string",
              "title": "Additional Field2",
              "default": "test 2"
            }
          }
        },
        {
          "properties": {
            "includeField": {
              "const": false
            },
            "additionalField": {
              "type": "string",
              "title": "Additional Field3",
              "default": "test 3"
            }
          }
        }
      ]
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions