Select widget for oneOf object structure #225
Replies: 1 comment
-
The problem with
To be able to support many use cases out of box and many more with custom extensions, the internal schema system must work as logic-less as possible. To know which Or it must try to match Or... many other ways to support specific ways to match/inject Check the Happy Path, background infos about what UI-Schema makes with the schema and why the "automatic matching" is important to work as safely as possible. As all those problems can be solved for specific cases, e.g. if you can guarantee that there is some But I'm open to find new solutions or special MUI Widgets for (some) object cases, if it is as generic and simple as possible, but I'm more thinking about something with Autocomplete. AlternativeThe general suggestion I always make for cases like yours: use e.g. e.g. here i've added an The Check the {
"title": "Config",
"type": "object",
"properties": {
"detail": {
"type": "object",
"properties": {
"type": {
"widget": "Select",
"type": "string",
"enum": [
"Section-A",
"Section-B"
]
}
},
"allOf": [
{
"if": {
"properties": {
"type": {
"const": "Section-A"
}
},
"required": [
"type"
]
},
"then": {
"title": "Selection A",
"type": "object",
"properties": {
"apiUrl": {
"title": "Apiurl",
"type": "string"
},
"defaultDuration": {
"title": "Defaultduration",
"type": "integer",
"default": 30
}
}
}
},
{
"if": {
"properties": {
"type": {
"const": "Section-B"
}
},
"required": [
"type"
]
},
"then": {
"title": "Selection B",
"type": "object",
"properties": {
"url": {
"title": "Apiurl",
"type": "string"
},
"defaultLength": {
"title": "defaultLength",
"type": "integer",
"default": 20
}
}
}
}
]
}
}
} |
Beta Was this translation helpful? Give feedback.
-
I really like ui-schema, as it offers lot's of features that allow custom styling and widgets, whereas combining json-schema forms at the same time.
However I was wondering if there's a widget that allows different variants of objects defined in the "oneOf" property and managed by the "Select" dialoge as e.g. described by the following schema:
If so, how do we configure this?
If not, do you think an implementation of a card field that renders the object context of the selected object would be hard to implement inside the select widget?
Beta Was this translation helpful? Give feedback.
All reactions