【发布时间】:2016-01-30 21:23:48
【问题描述】:
我刚刚为 Meteor 找到了这个很棒的 autoForm 包,我想将它与 select2 一起使用。
我的目标是使用 autoForm 轻松地为我的收藏创建一个输入表单。障碍是:如何使用另一个集合中的字段填充它以及如何使其多选?
在我的 lib/collections 中,我声明了一个 Meteor 集合:
Clients = new Mongo.Collection('clients');
Clients.attachSchema(new SimpleSchema({
clientName: {
type: String,
label: "Mandator Name",
max: 200
}
}));
现在我没有得到关于 autoForm 的文档。在大气页面(https://atmospherejs.com/aldeed/autoform)上,如果我没记错的话,我应该使用这样的东西:
{{#autoForm collection="Clients" id="insertClientForm" type="insert"}}
{{> afFieldInput name="clientName" options=options}}
{{/autoForm}}
然后像这样写一些JS:
Template.registerHelper({
options: function() {
return Clients.find({}, {fields: {clientName: 1}});
}
});
模板渲染得很好,我可以看到一个输入框。但是它不是多选,它根本不允许我选择任何值。
关于问题出在哪里的任何想法?
额外问题:如何在 autoForm 生成的选择输入上使用 select2? 编辑:使用 aldeed:autoform-select2 来使用 select2。
【问题讨论】:
-
刚刚自己解决了奖金问题。还有另一个名为 aldeed:autoform-select2 的包可以解决问题。
标签: javascript meteor meteor-autoform meteor-collection2 simple-schema