【发布时间】:2016-02-13 03:22:39
【问题描述】:
我正在尝试创建一个表单,以便在集合的嵌套数组中插入一个新元素。 这是我的架构:
Schemas.CampaignsSchema = new SimpleSchema({
'name': {
type: String
}
});
Schemas.ElectionsSchema = new SimpleSchema({
'campaigns': {
type: [Schemas.CampaignsSchema],
defaultValue: []
}
});
这是我的模板:
Template.campaignsNew.helpers({
schema() { return Schemas.CampaignsSchema; },
});
<template name="campaignsNew">
{{#autoForm
collection='Elections'
schema=schema
doc=doc
scope='campaigns'
id='insertCampaignForm'
type='update-pushArray'}}
<fieldset>
<legend>Add a Campaign</legend>
{{> afQuickField name='campaigns.$.name'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
</template>
所以自动表单生成了一个字段,但是当我点击提交时没有任何反应。
如果我启用 Autoform.debug() 我得到了:
SimpleSchema.clean:过滤掉会影响键“活动”的值,这是架构不允许的
SimpleSchema.clean:过滤掉会影响键“campaigns.$”的值,这是架构不允许的
SimpleSchema.clean:过滤掉会影响键“campaigns.$.name”的值,这是架构不允许的
有人知道吗?
【问题讨论】:
标签: meteor collections nested meteor-autoform