我已经获得了一些链接模式,并且正在尝试从主模式的表单中访问子模式的属性。我知道,这很难理解。代码可能会有所帮助:
//js
Collection = new Meteor.Collection('collection');
Schemas = {};
Schemas.secondary = new SimpleSchema({
unitType: {
type: String,
autoform: {
type: 'select',
options: //function with all the options
}
}
});
Schemas.primary= new SimpleSchema({
name: {
type: String,
},
units: {
type: [ Schemas.secondary ]
}
});
Collection.attachSchema(Schemas.primary);
//HTML
{{#autoForm collection="Collection" id="someId" type="insert"}}
{{> afQuickField name='name'}} // this works
{{> afQuickField name='units'}} // this works
{{> afQuickField name='units.unitType'}} // this doesn't work :-(
{{/autoForm}}我这样做的原因是因为我希望根据选择框的值有条件地显示辅助模式中的其他属性。我还尝试将表单放入表单中,然后运行{{#each afFieldNames name='"units"}},但也不能很好地工作。它不是只给我单元中包含的字段(即辅助模式),而是循环遍历主和辅助的所有字段。
有什么想法?我不喜欢这种模式,但我想不出另一种方法。
再次感谢所有人。数据库
发布于 2015-05-26 08:15:17
我自己也有这个问题。
试一试
{{> afQuickField scope='units.unitType' name='units.unitType'}} 如果您将修饰符转储到提交前钩子中,您应该能够看到子文档已成功填写
AutoForm.hooks({
someId: {
before: {
'insert': function(modifier) {
console.log(modifier);
}
}
}
});如果这对你有效,请告诉我!
一切顺利,埃利奥特
https://stackoverflow.com/questions/26748937
复制相似问题