Showing server side (back end) errors on the form in React standalone JSONForms

Is there any way to show the server-side (back-end) error on the fields after the form submission? The error might be related to specific field or to the form. I searched the doc and also read the source, and I found no way to do it after submit.
Imagine that the response of the submission is a list of errors, how can we pass it to the error object to render?

At the moment there is no easy way to set the errors manually. The current possible approaches are:

  • Hand over a custom AJV instance (for example by wrapping a regular instance) which not only returns the normal errors for the form, but also your additional errors.
  • Write a custom renderer so you get access to the internal dispatch method. There you can dispatch the setErrors action to update the errors how you want. Note however that the errors will be overwritten again with each update cyle, so you need to keep setting them with each render pass.
  • Instead of using JsonForms you can use your own copy of the JsonFormsStateProvider component which you can modify to your needs. For example to add a new errors prop which you can set from the outside of your component.

Should we add middleware support to JSON Forms at some point, then you could add custom errors by amending them for each update operation, and/or by saving the reference to the given dispatch and dispatch the setErrors action whenever you want.

Okay, Got it. Thanks for the response.

1 Like