-
Notifications
You must be signed in to change notification settings - Fork 168
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
How to use dynamic schemas for multiple fields #22
Comments
Maybe this works for you:
var typeSchemas = {
"type1": {
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Title 1"
},
"gender": {
"type": "string",
"title": "Gender",
"enum": [
"m",
"f"
]
}
},
},
"type2": {
"type": "object",
"properties": {
"title": {
"type": "string",
"title": "Title 2"
},
"otherfield": {
"type": "string",
"title": "Some other otherfield"
}
}
}
}; and change the resolver to: function (names, data, cb) {
var schemas = new Object();
schemas["$.nextfields"] = typeSchemas[data.type];
cb(schemas);
} |
Thank you for your reply! |
The reason is that this schema is different to the previous one (it does not have a |
Ok, the short answer is: Yes I am too stupid to transfer your example. :) Just for documentation purpose: https://jsfiddle.net/ajzmgkh4/1/ Thank you for your help! |
:) |
https://jsfiddle.net/hxh_robb/xk663z01/ I've added a new feature called "appendedProperties" to meet this requirement without using schemaResovler. Since schemaResovler is a kind of behavior for "dynamic" additional properties rendering(What I mean "dynamic" is that the additional properties definition is a CRUD record, the schemaResovler might made an ajax call for that and generate a returned schema). "appendedProperties" is much more suit for that if one just need a "fixed" additional properties definition. |
I am just wondering, how to add multiple fields based on one other field using the schemaResolver.
Lets say, I have a selectbox "type" with 2 options type1 and type2. Depending on this selectbox, I want to show 2 different sets of additional fields. I have tried the following:
But thats not working, since the
schemas["$.data"]
has to be a single property and not an set of properties. Is there any possibility to solve this?The text was updated successfully, but these errors were encountered: