load collections to a quickform in meteor

2019-09-08 09:23发布

问题:

I created two seperate schemas for payments collection and memberProfile. Now I need to create a quickform so I could load all the payments relevant to a unique memberProfile.

     //The code for memberPayment collection

MemberProfiles = new Mongo.Collection('memberProfiles');


RecipeSchema = new SimpleSchema({
name: {
    type: String,
    label: "Name"
},
desc: {
    type: String,
    label: "Description"
},
payments:{
    type: [PaymentSchema],
    autoValue: function () {
        return Payments.find({ memberId="uniqueId"});
    },

     defaultValue: function () {
         return Payments.find({memberId="uniqueId"});
    },

},

// The code for payments collection

 PaymentSchema = new SimpleSchema({
name:{
    type: String

},
amount:{
    type: String
},
memberId:{
    type: String
},


});

This code doesn't work.

回答1:

Looks like you're missing the schema attribute. Any autoform needs to take in a schema attribute that explicitly tells autoform to use that schema to generate the necessary form. Check this page out for demos using autoform.

{{> quickForm collection="theMongoCollection" id="theFormID" schema="theSchemaName" type="typeOfForm" }}