Skip to content

Conversation

tulir
Copy link

@tulir tulir commented Jan 16, 2017

This pull request allows you to make dependencies for fields so that if another field isn't in the value options, the field with the dependency will not be shown. This PR uses the internal field value watch system to notify fields of changes in their dependencies.

The dependency information is fetched from the dependencies field in the options field of the control. The dependencies field should be a map where the keys are the names of the fields depended on and the value is the expected value. The value may be an array to indicate multiple value possibilities.

Here's an example schema:

{
  "title": "An object",
  "type": "object",
  "properties": {
    "fieldOne": {
      "title": "I should be changed to 'foo'",
      "type": "string",
      "default": "bar"
    },
    "depender": {
      "title": "I depend on fieldOne to be 'foo'",
      "type": "string",
      "options": {
        "dependencies": {
          "fieldOne": "foo"
        }
      }
    }
  }
}

And the output it produces (bootstrap 3 theme)
Before: Before preview image
After: After preview image

btsimonh pushed a commit to btsimonh/json-editor that referenced this pull request May 26, 2021
btsimonh pushed a commit to btsimonh/json-editor that referenced this pull request May 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant