field-plugin
field-plugin copied to clipboard
Add custom errors hook and capability to prevent saving the page
Is your feature request related to a problem? Please describe.
I have played around with React template and made my first field type plugin in this new new API. Unfortunately, I found out that there is no error interception or some hook to prevent CMS from saving, so I could make custom error handling within the field type plugin.
Describe the solution you'd like My plugin is much more advanced and acts rather like a widget with input and some more inputs generated dynamically, so I have error handling to prevent invalid cases. The example could look like in the additional context.
My FieldPluginResponse.data.content
is not a string, but rather an object {}
, so I have to have custom error handling for better and UI with guided output.
I do not want to imply exact solution, but from top of my head there could be some setError
(similar to setContent
), so CMS could check it before saving the page and would generate the messages queue of single string and/or array of strings which are set by the field plugin. The rest could be part of the usual flow - that error icon next to Publish button to hint user to resolve listed errors.
Additional context