[英]Meteor AutoForm: form with id “asdf” needs either “schema” or “collection” attribute
我有一個要使用模式呈現的自動表單。 我在Template.name.helpers({:
Template.name.helpers({
getSchema: function() {
var schema = new SimpleSchema({
location: {
type: String,
label: "Start location"
}
});
return schema;
}
的HTML:
{{#autoForm schema=getSchema id="submitOfferLift" type="method"}}
但是我無法讓助手工作( 相關文檔 )。 此外,如果僅在template.js中定義schema = {...}
,並在自動表單中指定schema = "schema"
,則會收到一條消息,指出未在窗口范圍中定義schema。 此外,如果我在控制台中創建schema變量,則表單呈現就很好。
您的助手正在返回一個簡單的對象,而它應該已經在返回一個SimpleSchema實例
Template.name.helpers({
getSchema: function() {
var schema = new SimpleSchema({
location: {
type: String,
label: "Start location"
})
return schema;
}
})
另外,模板包含應使用>
而不是#
{{> autoForm schema=getSchema id="submitOfferLift" type="method"}}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.