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

Nested dynamic schema dependencies #1217

Closed
kalyan542 opened this issue Mar 12, 2019 · 10 comments
Closed

Nested dynamic schema dependencies #1217

kalyan542 opened this issue Mar 12, 2019 · 10 comments

Comments

@kalyan542
Copy link

I have select box A which has options option1, option2
if select option1 in select box A, populate another select box B with options NORMAL, CMC
If i select Normal in select box B, populate some fields name, age
If select CMC populate fields id, enable

I can able to populate dependency fields based on select box A but not with select box B.

{
type: "object",
properties: {
A: {
"title": A,
"type": "string",
"enum": [
"--select--",
"option1",
"option2",
],
"default": "--select--"
},
},
"dependencies": {
"A": {
"oneOf": [
{
"properties": {
A: {
"enum": [
"option1"
]
},
B: {
type: "string",
title: B,
enum: [
"NORMAL",
"CMC"
],
enumNames: [
"NORMAL",
"CMC"
]
},
name: {
type: "string",
title: "name"
},
age: {
type: "string",
title: "age"
},
}
},
]
}
}
}

@epicfaace
Copy link
Member

@kalyan542 Can you please post a playground link (https://mozilla-services.github.io/react-jsonschema-form) demonstrating the issue? That will help us get to the problem faster.

@epicfaace epicfaace added the needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc. label Mar 28, 2019
@kalyan542
Copy link
Author

kalyan542 commented Mar 29, 2019

Please see this below example.
https://jsfiddle.net/kcherukuri/3asr5Lo2/3/

@kalyan542
Copy link
Author

@kalyan542 Can you please post a playground link (https://mozilla-services.github.io/react-jsonschema-form) demonstrating the issue? That will help us get to the problem faster.

Added jsfiddle playground link

@epicfaace
Copy link
Member

@kalyan542 What are you expecting? When I select "CMC" I get the following fields, which seems to accord with what the schema describes:

image

@epicfaace epicfaace added awaiting response question and removed needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc. labels Mar 29, 2019
@kalyan542
Copy link
Author

kalyan542 commented Mar 29, 2019

Select option1 in select box A show all the fields B,Name,Age,Id,Enable --> this case is working as expected,Struggling with below cases.

only show name and age fields If i select CMC in Select box B
only show id and enable fields If i select NORMAL in Select box B

@epicfaace
Copy link
Member

@kalyan542 Does this schema work for you? https://jsfiddle.net/jhocLqvb/

@kalyan542
Copy link
Author

B select box has to show after A select box. if i add uiSchema={uiSchema} for fields order getting this error "Invalid root object field configuration:uiSchema order list contains extraneous property 'B'."

@epicfaace
Copy link
Member

That error should not come in the latest playground version, since #814 was merged: Playground link. However, this fix has not been released in the latest version yet.

However, there seems to be another problem -- the ui:order is not being respected, probably because of something related to nested dependencies.

@ezzadeen
Copy link

This issue seems too old.
I'm using @rjsf/core": "^3.2.1. I don't have this problem.

`
{ "definitions": {
"Root": {
"type": "object",
"properties": {
"first_dependency": {
"type": "string",
"enum": ["yes", "no"]
}
},
"dependencies": {
"first_dependency": {
"oneOf": [
{
"properties": {
"first_dependency": {
"enum": ["yes"]
},
"properties": {
"title": "",
"type": "object",
"properties": {
"nested_dependency": {
"type": "string",
"enum": ["yes", "no"],
"default": "no"
}
},
"dependencies": {
"nested_dependency": {
"oneOf": [
{
"properties": {
"nested_dependency": {
"enum": ["yes"]
},
"properties": {
}
}
},
{
"properties": {
"nested_dependency": {
"enum": ["no"]
},
"properties": {}
}
}
]
}
}
}
}
}
]
}
}
}
}
}

`

@nickgros
Copy link
Contributor

Per @ezzadeen this seems to be fixed. Please open a new issue if any related issues persist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants