Hello, I am using JSONForms to build a React based, general interactive authoring tool. the current form is for a quizzing interaction and needs a lot of nested and dynamic arrays/objects. the dropdown “questionType” will affect the fields which come after. I’ve noticed HIDE and SHOW rules are not working when applied to any item in an array, and I cant tell if my scoping is just wrong or it’s a limitation of the system.
I’ve included a reduced version of my schemas below. These rules seem to work when the array object isn’t in the array. I’ve tried changing the scopes, effects and schemas around to see if it helped, but unsure what’s causing the fields to show up.
schema.json
{
"type": "object",
"properties": {
"questions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"questionType": {
"type": "string",
"enum": ["Choice A", "Choice B", "Choice C"]
},
"answerText": {
"type": "string",
"description": "Note: you do not need an enumerator, this will be added automatically."
},
"feedBackText": {
"type": "string",
"description": "Feedback text presented if the answer is selected"
},
"scoreValue": {
"type": "integer",
"description": "If correct, the answer should have a score"
}
}
}
}
}
}
uischema.json
{
"type": "VerticalLayout",
"elements": [
{
"type": "Control",
"scope": "#/properties/questions",
"label": "Questions (Use the + icon to add more questions.)",
"options": {
"showSortButtons": true,
"detail": {
"elements": [
{
"type": "Control",
"label": "Question Type",
"scope": "#/properties/questions/questionType"
},
{
"type": "Control",
"label": "Answer Text",
"scope": "#/properties/questions/answerText",
"rule": {
"effect": "SHOW",
"condition": {
"scope": "#/properties/questions/questionType",
"schema": { "enum": ["Choice A"] },
"NOTE": "based on https://jsonforms.io/docs/uischema/rules"
}
}
},
{
"type": "Control",
"label": "FeedBack Text",
"scope": "#/properties/questions/feedBackText",
"rule": {
"effect": "SHOW",
"condition": {
"scope": "#/properties/questions/questionType",
"schema": { "const": "Choice B" },
"NOTE": "https://jsonforms.io/examples/rule"
}
}
},
{
"type": "Control",
"label": "Score Value",
"scope": "#/properties/questions/scoreValue",
"rule": {
"effect": "SHOW",
"condition": {
"scope": "#/properties/questions/questionType",
"schema": { "const": "Choice C" }
}
}
}
]
}
}
}
]
}
[original thread by cjmorrison]