-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
Unexpected behavior during oneOf/anyOf option select #181
Comments
It's a known issue, but it's not a bug, per se. To generate the UI, we first look at the data and then try to find the matching anyOf subschema, and then generate the form. The problem here is that both the subschemas in So the UI generator matches the string data with the first subschema and generates the form for that. This probably won't be fixed. However, there's a workaround. Instead of using string type for subschema, you will need to use an object type and then you can set some hidden unique id field on the subschemas so that the UI generator can differentiate between them. Example: {
"anyOf": [
{
"type": "object",
"title": "Lengua escrita",
"keys": {
"id": {"const": "option_1", "widget": "hidden"},
"systype": {"const": "string_choices", "widget": "hidden"},
"value": {
"type": "string",
"title": "Lengua escrita",
"default": "",
"required": null,
"choices": [
"A",
"B"
]
}
}
},
{
"type": "object",
"title": "Lengua tecleada",
"keys": {
"id": {"const": "option_2", "widget": "hidden"},
"systype": {"const": "string_choices", "widget": "hidden"},
"value": {
"type": "string",
"title": "Lengua tecleada",
"default": "",
"required": null,
"choices": [
"C",
"D"
]
}
}
}
]
} Resulting data: {
"corpus": "Corpus Test",
"Tipos textuales": {
"items": [
{"id": "option_1", "systype": "string_choices", "value": "A"},
{"id": "option_1", "systype": "string_choices", "value": "C"},
]
}
} |
Now it is working! It is not the first time I open an issue here and you always reply asap. Thanks for your attention and your work. Seeing that this is a known issue, would be a good idea to mentioned it in the troubleshooting or to add some validator to check this problem? I can help you with any of that. (It was not the first time I run into this problem with anyof, but I don't remember what I did that I was able to fix it) |
Thanks for the kind words. Yeah, some sort of check/validation sounds a good idea but I'm putting off any major changes for the time being. Right now I'm doing a complete rewrite of the javascript library. We have some ideas to fix this issue (e.g.: this comment on #160). But I agree, this should be documented. I'll try to update the documentation soon. Until then I'll mark this issue as a bug and leave it open. |
Hi, I am wondering if I am doing something wrong. I have this valid JSON Schema:
But when I try to select an item, I get this behavior:
I check the documentation and I couldn't find where I am missing something. Thanks in advance!
The text was updated successfully, but these errors were encountered: