Meteor AutoForm:带有id" asdf"的表单需要"架构"或"收集"属性

时间:2015-11-06 15:26:11

标签: javascript meteor meteor-autoform

我想要使用模式渲染的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",我会收到一条消息,说明在窗口范围内没有定义模式。此外,如果我在控制台中创建架构变量,表单呈现就好了。

1 个答案:

答案 0 :(得分:1)

你的助手正在返回一个简单的对象,而它应该返回一个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"}}
相关问题