formio.js icon indicating copy to clipboard operation
formio.js copied to clipboard

Better error handling of subform/nested forms when they fail to load.

Open llemire-exp opened this issue 11 months ago • 2 comments

Is your feature request related to a problem? Please describe. We implemented formio within our own system, each form has a permission level that can be updated, therefore when we have a main form that has another form as subform using the "nested form" component, it is possible that in the future, the subform becomes inaccessible because of a change in permissions or if someone else deletes the subform, therefore when our user renders the main form he won't be able to load the subform.

Currently, if a nested form fails to load, formio renders the string "loading..." forever. No error handling is available whatsoever which can make the form look awkward. Examples at the end.

Describe the solution you'd like There is 2 part to the solution: 1- A better way to display an error when a subform cannot be loaded. A default behavior could be implemented and the error rendering could be customizable from the edit form of a nested form or dynamically set from a callback passed to the rendering options. 2- A way to know if a subform failed to load when rendering the form, something like a callback that could be set in the options when rendering a form, for example.

Having a way to know which form failed to load and even receive the error from the fetch would be great since it could let us change the error message dynamically depending on the reason why loading the subform failed.

Describe alternatives you've considered We could try to parse the source of the form being rendered and replace all nested form components that have subforms that cannot be rendered. However this does not take into consideration nested forms that themselves have other nested forms.

Additional context

Image Result: Image

for solution # 1: In the form, instead of just loading, it could be an standard alert from bootstrap

Image

There could be a standard error message, or the error message could be set from the nested form edit form, or even from a callback that is passed to the options.

llemire-exp avatar Jan 20 '25 20:01 llemire-exp

Hey @llemire-exp thanks for the detailed write up. I'll get this in front of the team and see if we can get it resourced. As always, PRs are welcome as well!

brendanbond avatar May 15 '25 21:05 brendanbond

A ticket has been created for review: For internal reference: FIO-10169

lane-formio avatar May 16 '25 18:05 lane-formio