【发布时间】:2015-04-03 01:43:05
【问题描述】:
我使用aldeed:autoform 来渲染表单并通过Meteor.method() 运行其结果。我的表单如下所示:
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;
}
}
}
});
但是,它似乎永远不会到达这个钩子。
如何获取路由参数并将其与我的表单一起传递给具有自动表单的流星方法?
【问题讨论】:
标签: javascript meteor meteor-autoform