我有一个想要使用模式呈现的autoform。我在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"}}然而,我不能让帮助器工作(relevant docs)。此外,如果我只是在template.js中定义schema = {...},并在autoform中指定schema = "schema",我会得到一条消息,指出该模式未在窗口范围中定义。此外,如果我在控制台中创建schema变量,则表单呈现得很好。
发布于 2015-11-06 23:29:16
您的帮助器返回一个简单的对象,而它应该返回一个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"}}https://stackoverflow.com/questions/33570101
复制相似问题