Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add dependency system #718

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

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.

None yet

1 participant