我有这个架构:
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"
如何使用快速表单?