Closed ashwanikumar04 closed 8 years ago
You should return the error inside the callback, I think:
exports.preSave = function (req, res, args, next) {
next(new Error('Something bad happened!'));
}
Thanks. I tried similar way. but this way the page is changed to the list of the items. I want the user to be on same page with error shown.
Just by looking at the code I don't think that's possible.
I managed to keep the user on the same page but no error is shown. I am using following code
console.log("This is not active");
req.session.error = "This is not active";
res.redirect(res.locals.root + '/'
+ args.slug
+ '/'
+ pk);
return;
Still not able to show the error. Any idea?
That's because the error message inside the editview is not dynamic https://github.com/simov/express-admin/blob/master/views/editview.html#L14
See how this is implemented in the listview for example https://github.com/simov/express-admin/blob/master/views/listview.html#L23
Hello: Thanks for this awesome module. I am trying to use this for one of my project. I want to run custom validation in presave event and if the validation is failed I want to stop the save and show user an error message.
I tried setting error in Presave event but it did not work.
Can you suggest any way here. Thanks.