meteormeteor-autoformsimple-schemaquickform

show limit fields on autoForm


I have this schema:

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",
  }
});

I use quickForm for insert to mongoDB, whit following code:

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

and autoForm generate for me a form with all of schema's fields.

but I want only limit fields to show to user on autform, for example these fields:

title, price, image, email, phoneNumber, desc

and I fill some fields my self, for example these fields:

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

how can I use quickForm?


Solution

  • You can use afQuickfields

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

    else you can use type 'hidden' in schema

    _cityId: {
    type: String,
    label: "City ID",
    autoform:{
      type:"hidden"
      } 
    }