0
我使用aldeed:autoform
來渲染表單並通過Meteor.method()
運行結果。我的表單看起來如下:用流星方法提交url參數與表格
SelectPlanTemplates = new SimpleSchema({
templates: {
type: [String],
autoform: {
options: function() {
return PlanTemplates.find().map(function(doc) {
return { label: doc.title, value: doc._id };
});
},
noselect: true
}
},
userId: {
type: String,
allowedValues: function() {
return Meteor.users.find().map(function(doc) {
return doc._id;
});
},
autoform: {
omit: true
}
}
});
在我的模板上,我只做了以下操作。
+ionContent
+quickForm(schema="SelectPlanTemplates" id="SelectPlanTemplatesForm" type="method" meteormethod="createPlanFromTemplates")
我的網址的結構類似/plan/from_templates/{:userId}
。我試圖創建一個鉤子來提交它之前添加用戶ID。
AutoForm.hooks({
SelectPlanTemplatesForm: {
before: {
method: function(doc) {
doc.userId = Router.current().params.userId;
return doc;
}
}
}
});
但是,它似乎從來沒有得到這個鉤子。
我將如何採取路線參數,並將其與我的表單傳遞給自動形式的流星方法?