Reputation: 394
I don't understand how to import
my methods so that AutoForm can see them. Based on the 1.3 best practices, all inserts/updates/deletes should be blocked on the client, and we should use methods instead. These should be imported on a page-by-page basis on the client.
I tried removing the quotes around the meteormethod
attribute, and import
ing the Method in the template's JS file, but this returns an error method.js:11 Uncaught Error: When form type is "method", you must also provide a "meteormethod" attribute
.
What's the best practice for this? How do I tell AutoForm where to find my method?
Upvotes: 0
Views: 128
Reputation: 394
I solved my own problem. Don't import
anything, just reference the internal Meteor
method name in AutoForm's meteormethod
attribute.
For example (if you're using ValidatedMethod
):
export const insertProject = new ValidatedMethod({
name: 'projects.insert',
validate: Projects.schema.validator(),
run(fields) {
Projects.insert(fields);
}
});
You'd then use:
{{> quickForm collection=projects id="insertProjectForm" type="method" meteormethod="projects.insert"}}
(note the meteormethod
attribute is the same as the name
attribute of the ValidatedMethod
)
Ref: https://themeteorchef.com/snippets/using-validated-methods/
Upvotes: 2