在 autoForm 上显示限制字段

show limit fields on autoForm

我有这个架构:

AdsSchema = new SimpleSchema({
  title: {
    type: String,
    label: "Title"
  },
  _cityId: {
    type: String,
    label: "City ID"
  },
  _categoryId: {
    type: String,
    label: "Category ID"
  },
  insertedDateTime: {
    type: Date,
    label: "Inserted Date Time",
    autoValue: function() {
      if (this.isInsert) {
        return new Date();
      } else if (this.isUpsert) {
        return {$setOnInsert: new Date()};
      } else {
        this.unset();  // Prevent user from supplying their own value
      }
    }
  },
  insertedBy: {
    type: String,
    label: "Inserted By"
    defalutValue: Meteor.user().username
  },
  price: {
    type: Number,
    label: "Price"
  },
  image: {
    type: Object,
    label: "Image",
    optional: true
  },
  email: {
    type: String,
    label: "Email"
  },
  phoneNumber: {
    type: String,
    label: "Phone Number",
    optional: true
  },
  desc: {
    type: String,
    label: "Description",
    autoform: {
      afFieldInput: {
        type: "textarea",
        rows: 10
      }
    }
  },
  quickOrNot: {
    type: Boolean,
    label: "Quick Or Not",
  }
});

我使用 quickForm 插入到 mongoDB,代码如下:

{{> quickForm schema="AdsSchema" collection="Ads" id="insBaseAds" type="insert"}}

autoForm 为我生成了一个包含所有架构字段的表单。

但我只想限制在自动表单上向用户显示的字段,例如这些字段:

title, price, image, email, phoneNumber, desc

我自己填写了一些字段,例如这些字段:

_cityId: "test",
_categoryId: "test",
insertBy: "test"

如何使用 quickForm?

您可以使用 afQuickfields

{{>afQuickFields  fields="title, price, image, email, phoneNumber, desc"}} 

否则您可以在架构

中使用类型'hidden'
_cityId: {
type: String,
label: "City ID",
autoform:{
  type:"hidden"
  } 
}