3
我有一些鏈接架構,並試圖從主架構的窗體訪問子模式的屬性。我知道這是一口。代碼可以幫助:流星autoform訪問嵌套屬性
//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"}}
,但那也不是很有效。它不是僅給出單位中包含的字段(即輔助模式),而是循環遍歷主要和次要的所有字段。
想法?我沒有結婚這種模式,但我想不出另一種方式。
再次感謝所有。 db
嘗試'{{> afQuickField名= 'units.1.qty'}} {{> afQuickField名= 'units.1.unitType'}} ' – juanpastas 2014-11-05 04:33:21
的答案是爲您繼承的每個模式選項創建自定義子模板。我會稍微張貼一個fildde。 – 2014-11-05 20:13:09