0

我有这个架构:

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 为我生成一个包含所有模式字段的表单。

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

title, price, image, email, phoneNumber, desc

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

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

如何使用快速表单?

4

1 回答 1

1

您可以使用 afQuickfields

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

否则你可以在模式中使用“隐藏”类型

_cityId: {
type: String,
label: "City ID",
autoform:{
  type:"hidden"
  } 
}
于 2016-03-02T15:32:43.273 回答