Meteor Autoform/SimpleSchema - quickform (type="update") 不工作

Meteor Autoform/SimpleSchema - quickform (type="update") not working

我认为我有一个简单的 SimpleSchema,目前我有两个模板。一个包含用于将新文档插入集合的快速表单,另一个也是一个应该从第一个模板更新文档的快速表单。

插入表单工作正常,但是当我尝试加载更新模板时,我的控制台显示以下错误并且提交按钮不起作用。据有过类似问题的人说,这个错误一般是某个递归函数引起的,但是我到处都找不到。

Exception from Tracker recompute function:
debug.js:41 RangeError: Maximum call stack size exceeded
    at Object (native)
    at isObject (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1000:18)
    at isBasicObject (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1024:10)
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1147:15)
    at http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1159:11
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22)
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1155:9)
    at http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1159:11
    at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?0a80a8623e1b40b5df5a05582f288ddd586eaa18:159:22)
    at parseObj (http://localhost:3000/packages/aldeed_simple-schema.js?e210968641793751997ffe233af33b53af8566e4:1155:9)

这是我的两个模板:

<template name="newWeddingPage1">
    <div class="  col-sm-10 col-sm-offset-1">
    <div class="  col-md-6">
        <div class="well well-sm">

        {{> quickForm collection="Weddings" id="insertWeddingInfo1" omitFields="email, phone, name, price" type="insert"}}

    </div>
    </div>

    <div class="  col-md-6">
        <div class="well well-sm">
        {{#each theweddingdetails}}
        <h1 id="price">{{duration}}</h1>
        {{/each}}


    </div>
    </div>



  </div>
</template>


<template name="newWeddingPage2">
    <div class="  col-sm-10 col-sm-offset-1">
    <div class="  col-md-6">
        <div class="well well-sm">
        {{#each theweddingdetails}} 
        {{> quickForm collection="Weddings" id="updateWeddingInfo1" doc="this" omitFields="email, phone, name, price" type="update"}}
        {{/each}}

    </div>
    </div>


  </div>
</template>

这里是我的简单架构:

Weddings.attachSchema(new SimpleSchema({

  address: {
    type: String,
    label: "Address",
    optional: true
  },
  startDate: {
    type: Date,
    label: "Date of shooting",
    optional: false,
  },
  startTime: {
    type: String,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "time"
      }
    }
  },
  duration: {
    type: Number,
    label: "Duration (in hours)",
    optional: true
  },
  price: {
    type: Number,
    label: "Price",
    optional: true,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue:function(){ return 0 }
  },
  email: {
    type: String,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "email"
      }
    }
  },
  phone: {
    type: Number,
    optional: true,
    autoform: {
      afFieldInput: {
        type: "tel"
      }
    }
  },
  name: {
    type: String,
    label: "Contact Person",
    optional: true
  },
  createdBy: {
    type: String,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue:function(){ return this.userId }
},
createdAt: {
    type: Date,
    autoform: {
      type: "hidden",
      label: false
    },
    autoValue:function(){ return new Date(); }
}
}));

有人知道我哪里出错了吗?

最近几个小时一直在研究位:/

在您的更新表单中,您有 doc="this" ,这意味着您只是传递一个字符串 "this" 作为您的文档。

试试 doc=this ,不带引号。这样,您将传递上下文变量 this 作为您的文档。我假设在您的路由器或其他地方您已经将适当的文档作为您的数据上下文传递,以便它可以在 this

中使用