Hello. I am trying to figure out the correct way to differentiate between server-side error messages and AutoForm-related messages when displaying them on the client.
For example, my autoForm:
{{#autoForm schema=get_create_user_form_schema id="create_user_form" type="method" meteormethod="create_user"}}
And in server/lib/method.js
:
create_user : function(doc) {
try {
// Returns the newly created user id.
var new_user = Accounts.createUser({
// Create user.
});
} catch (error) {
throw new Meteor.Error("Server error", error);
}
}
And in client/lib/helpers.js
:
AutoForm.hooks({
create_user_form: {
// Called when a new user has been created.
// Result contains the server response.
onSuccess: function(formType, result) {
FlashMessages.sendSuccess("result: " + result);
},
// Called when the submit operation fails.
onError: function(formType, error) {
FlashMessages.sendError("Error creating user: " + error);
}
}
});
When a form contains invalid stuff, the form fields are highlighted as expected but the validation error message is also sent to onError. I need a way to differentiate between AutoForm’s error messages and the server’s error messages.
Thanks