-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Validate before opening draft preview #106
Comments
Hi @cannorin That would be a nice feature to include 👍🏻 I don't think I knew that Strapi allowed empty required fields for drafts. I have to agree that custom fields are currently lacking a proper method for frontend validation, but with this being a custom plugin it won't be limited in that way. It's also important to note that plugin configurations can include callbacks, but those callbacks will only be usable on the server - they are not passed to the frontend at all. After looking at this compileWithHooks function in the plugin, it might just need an additional hook to handle validation when clicking the preview button (same with the copy button). I'm thinking the custom validation hook would return an object like below which would prevent the button from opening the preview link and instead, display a toast error. This is just off the top of my head. {
result: false,
error: 'Here is a custom error message for the toast UI in Strapi.',
} Does this sound like it would be helpful for your situation or did I miss anything? |
I was wondering how can I possibly trigger the built-in validation feature (the one that triggers when you try to publish your entry). If that is not possible, yes, custom validation hooks would be the best thing we can have right now. |
@cannorin Hmm if I'm not mistaken, when you attempt to publish an entry Strapi will This sounds like a feature worth implementing if I did not already mention that 👍🏻 |
Strapi allows draft entries not to have all the required fields, which is great since users can save an unfinished entry as a draft and finish it later.
However with this plugin, users can try to open a preview of a draft entry, which may lack the fields needed to display the preview page correctly (e.g. the content of the page). I can workaround this by adding error messages to my frontend app, but it should be more intuitive for users to fail early and display validation errors on Strapi.
This may be difficult to implement however, as I can find someone on the official forum who are struggling to trigger validation from their plugin: https://forum.strapi.io/t/trigger-validation/17103.
The text was updated successfully, but these errors were encountered: