Hi!
Is there a possibility to use Categorization Example - JSON Forms to automatically navigate to a specific category (tab) depending on answers given in a previous category?
Real-Life Example:
Imagine we’re creating an online quiz for users to discover their vacation destination:
Initial Category - Vacation Type:
The quiz starts by asking, “Do you prefer a beach vacation?” with a simple Yes/No question.
If the user selects “Yes,” they would be automatically directed to the next category that asks about their beach preferences.
Alternative Path:
If the user selects “No,” they might be taken to a different category that explores other vacation types
Is this achievable in JsonForms?
Perhaps by a custom renderer?
We don’t have support for this in our off-the-shelf renderers. Custom renderers have full control over their rendered output, therefore you can implement any use case with them, including yours.
However you might want to think about a different implementation approach: Instead of implementing all the branching logic within a custom renderer, you could implement the “form wizard” outside of JSON Forms, and then just use JSON Forms to render each small form. That’s likely easier to implement.
@sdirix Thank you for your response! I get your point regarding splitting to separate json schemas controlled by a wizard, but this approach would block a different requirement that I have.
I need to establish UiSchema rules across various categories.
For instance, I’d like to set a UiSchema SHOW rule (Rules - JSON Forms):
if category1.isInsured field is false,
then category2.vacationInsurancePlan should be visible.
To achieve this functionality, it seems necessary to utilize one <JsonForms/> component for handling single schema with multiple categories.
Given that, I would be grateful for any suggestions you may have regarding the implementation of the navigation I mentioned in my previous post.
Thank you!
If you fully leverage the approach, then you don’t need any UI Schema rules. The “rules” should instead be handled by the wizard, for example if isInsured is false, then the next form schema should not even contain vacationInsurancePlan.
As noted above, custom renderers give you full control. In your case you need a specialized Categorization renderer which is either hard coded on how to behave or consumes some custom “navigation rules” from the UI Schema. The categorization renderer can then listen to the form wide data changes and focus the category you would like to see.
Note that all our off-the-shelf renderers use exactly the same mechanisms as “custom” renderers, in fact from the view of the framework there is no difference between our offered renderers and custom renderers. Therefore you can take a look at how we implemented our own renderers for inspiration.