showWhen Widget not working as expected
Submitted by ftawebdev on Tue, 05/16/2023 - 12:15
Forums:
Hi, I'm trying to use the showWhen widget in the following semantics, but it just ends up printing the string [field:select:showWhen:inputType]
Any ideas what I'm doing wrong?
[ { "name": "categoriesList", "label": "Categories List", "importance": "high", "type": "list", "min": 1, "widgets": [ { "name": "VerticalTabs", "label": "Default", "importance": "high" } ], "field": { "name": "categoryGroup", "label": "Category Group", "type": "group", "fields": [ { "name": "categoryName", "label": "Category Name", "type": "text" }, { "name": "questionList", "label": "Question List", "type": "list", "min": 1, "field": { "name" :"questionsGroup", "label": "Questions Group", "type": "group", "fields": [ { "name": "questionType", "label": "Question Type", "importance": "high", "type": "select", "options": [ { "label": "Multiple choice", "value": "multipleChoice" }, { "label": "Text", "value": "text" } ], "default": "multipleChoice" }, { "name": "inputType", "label": "Multiple choice type", "importance": "high", "type": "select", "widget": "showWhen", "showWhen": { "rules": [ { "field": "questionType", "equals": "multipleChoice" } ] }, "options": [ { "label": "Multiple answers", "value": "checkbox" }, { "label": "Single answer", "value": "radio" } ], "default": "checkbox" }, { "name": "question", "label": "Question", "importance": "high", "type": "text" }, { "name": "alternatives", "label": "Answer alternatives", "type": "list", "importance": "high", "entity": "Alternative", "min": 2, "field": { "type": "group", "name": "alternative", "label": "Alternative", "fields": [ { "name": "text", "label": "Text", "importance": "high", "type": "text" }, { "name": "feedback", "type": "group", "label": "Feedback", "importance": "low", "optional": true, "fields": [ { "name": "chosenFeedback", "type": "text", "widget": "html", "label": "Message displayed if answer is selected", "importance": "low", "description": "Message will appear below the answer on \"continue\" if this answer is selected.", "optional": true, "tags": [ "strong", "em", "sub", "sup", "a", "code" ] }, { "name": "notChosenFeedback", "type": "text", "widget": "html", "label": "Message displayed if answer is not selected", "importance": "low", "description": "Message will appear below the answer on \"continue\" if this answer is not selected.", "optional": true, "tags": [ "strong", "em", "sub", "sup", "a", "code" ] } ] } ] } } ] } } ] } } ]
otacke
Tue, 05/16/2023 - 20:06
Permalink
Presumably you are not
Presumably you are not loading the show when widget library among the editorDependencies of library.json.
ftawebdev
Wed, 05/17/2023 - 02:20
Permalink
Correct! Thank you. Is there
Correct! Thank you.
Is there a limitation of only being able to use one instance of the widget per semantics file, or semantics branch? I tried to use two but it just ignores the second one.
otacke
Wed, 05/17/2023 - 09:41
Permalink
No, you can have multiple
No, you can have multiple ones. But the widget has in fact limitations.
ftawebdev
Wed, 05/17/2023 - 02:20
Permalink
Also just realised this is in
Also just realised this is in the wrong forum, sorry bout that. Feel free to move it mods if it bothers you.
otacke
Wed, 05/17/2023 - 09:41
Permalink
I can't move it, I do not
I can't move it, I do not belong to H5P Group :-)
ftawebdev
Thu, 05/18/2023 - 13:08
Permalink
ShowWhen widgets cannot be
yep that was the one, cheers