Reputation: 142
When using autoform with type="method-update" meteormethod="someMethod"
the method will not actually get called.
The autoform I am having trouble with:
{{#autoForm id="archiveIssue" type="method-update" meteormethod="editIssue" collection="Collections.Issues" validation="keyup" doc=doc autosaveOnKeyup="true" resetOnSuccess="true"}}
<fieldset>
{{> afQuickField name="Archived.Archived_By" id="Archived.Archived_By" autocomplete="off"}}
{{> afQuickField name="Archived.Archive_Notes" id="Archived.Archive_Notes" autocomplete="off" rows=5}}
<div>
<button type="submit" class="btn btn-primary" data-toggle="modal" data-target="#archiveIssue">Submit</button>
<button type="reset" class="btn btn-default">Reset</button>
</div>
</fieldset>
{{/autoForm}}
This is the method that I am trying to call (The PRINT never shows up in the in the server console):
editIssue: function(doc) {
console.log("PRINT");
Collections.Issues.update({
"_id": doc._id
},
{
$set: {
"Archived.Archived": true,
"Archived.Archived_By": doc.Archived_By,
"Archived.Archive_Notes": doc.Archive_Notes
}
});
}
The 2 functions that should help get the doc:
Template.archiveIssue.helpers({
doc: function () {
var tmp = Session.get("archiveDoc");
return tmp;
}
});
Template.archiveIssueModal.events({
"click .archiveButton": function (event) {
Session.set("archiveDoc", this);
}
});
Schemas
Schema.Archived = new SimpleSchema({
Archived: {
type: Boolean,
optional: true
},
Archived_By: {
type: String,
optional: true
},
Archive_Notes: {
type: String,
max: 200,
optional: true
}
});
Schema.Issues = new SimpleSchema({
Description: {
type: String,
max: 500,
optional: true
},
Comments: {
type: [Schema.Comments],
max: 500,
optional: true
},
User: {
type: String,
label: "User",
optional: true
},
Archived: {
type: Schema.Archived,
optional: true
},
});
Upvotes: 1
Views: 477
Reputation: 21
Not sure if you need an answer now. You need to define with Meteor.methods like this.
Meteor.methods({
demoSubmission: function () {
Upvotes: 1