【发布时间】:2016-01-31 21:02:42
【问题描述】:
我有一个项目集合和 Meteor.users 集合。我的目标是将项目的文档_id添加到用户名。
HTML:
<template name="insertName">
{{#each projectList}}
{{> projectView}}
{{/each}}
</template>
<template name="projectView">
{{#autoForm collection="Meteor.users" id="insertUser" type="insert"}}
{{> afQuickField name="username"}}
// From here I can access the _id property from the projects collection
// Question: How do I pass it to my form without creating an input field?
{{/autoForm}}
</template>
JS:
Meteor.users = new Meteor.Collection('projects');
Meteor.users.attachSchema(new SimpleSchema({
username: {
type: String,
max: 50
},
projectId: {
type: String,
max: 20
// Use autoValue to retrieve _id from projects collection?
}
});
使用上面的 HTML 代码,我知道我可以这样写:
{{> afQuickField name='projectId' value=this._id}}
但是,这会创建一个我不想要的输入字段。如何在没有可见输入字段的情况下将 _id 传递给我的 autoForm?或者也许有人可以为我指明不同的方向?
【问题讨论】:
标签: javascript meteor meteor-autoform meteor-collection2 simple-schema