简体   繁体   English

Meteor Autoform不会更新收藏集

[英]Meteor Autoform doesn't update the collection

I have problem where my update and update-pushArray doesn't really update or add something to my array. 我的问题是我的update和update-pushArray并没有真正更新或向数组添加任何内容。

My template is this: 我的模板是这样的:

<template name="PersonShow">
<div class="container">
    <div class="user-data">
        <h2>{{name}}</h2>
        {{> quickForm id="PersonShow" type="update" collection="Registry" doc=this fields="isActiveEmployee"}}
    </div>
    <div class="device-data">
        {{#each device}}
        <h3><p>Device: {{type}}</p></h3>
        <h3><p>Quantity: {{quantity}}</p></h3>
        {{#autoForm id="PersonShow" type="update" collection="Registry" doc=this}}
        {{> afQuickField name="device.0.isInUse"}}
        {{> afQuickField name="comment"}}
        <button type="submit" class="btn btn-primary">Submit</button>
        {{/autoForm}}
        {{/each}}
    </div>
    <div class="add-new-device">
        {{> quickForm id="PersonShow" type="update-pushArray" collection="Registry" doc=this scope="device"}}
    </div>
</div>
</template>

and my collections: 和我的收藏:

Registry = new Mongo.Collection("registry");

Registry.attachSchema(new SimpleSchema({
  name: {
    type: String,
    label: "First and lastname",
    max: 200,
    optional: false
  },
  device: {
    type: Array,
    optional: true
  },
  'device.$': {
    type: Object
  },
  'device.$.type': {
    type: String
  },
  'device.$.isInUse': {
    type: String,
    optional: true,
    autoform: {
      options: [
        {label: "Yes", value: "Yes"},
        {label: "No", value: "No"}
        ]
    }
  },
  'device.$.serialNumber': {
    type: String,
    optional: true
  },
  'device.$.quantity': {
    type: Number,
    min: 0
  },
  isActiveEmployee: {
    type: String,
    optional: false,
    autoform: {
      options: [
        {label: "Yes", value: "Yes"},
        {label: "No", value: "No"}
        ]
    }
  },
  comment: {
    type: String,
    label: "Comments",
    optional: true,
    max: 1000
  },
}));

Nothing really happens when I press the update/update-pushArray, nothing gets sent to collection. 当我按下update / update-pushArray时,什么也没有发生,什么也没有发送到集合中。

Update works if I do it like this: 如果我这样做,更新就可以了:

{{> afQuickField name="device"}} but I only want to update one specific field in my array. {{> afQuickField name="device"}}但我只想更新数组中的一个特定字段。

Also for update-pushArray I want to add things to my array device 同样对于update-pushArray我想将东西添加到我的阵列device

Can anybody see whats wrong with this? 有人可以看到这有什么问题吗?

Problem was related to the templates. 问题与模板有关。 When I put each form to different template, the problem was solved. 当我将每个表单放入不同的模板时,问题就解决了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM