0
votes

I'm getting this console message when displaying a group of update forms together. As far as I can tell I've followed the Autoform example correctly. Can anyone tell me what I'm doing wrong?

SimpleSchema.clean: filtered out value that would have affected key "_id", which is not allowed by the schema

Path: form.html

{{#each student}}
    {{#autoForm id=makeUniqueID type="update" collection="StudentHistory" doc=this}}
    <div class="panel panel-default edit-profile-margin-pannel">
        <div class="panel-body">
            {{> afQuickField name='class'}}                                     
        </div>                                          
    </div>  
    {{/autoForm}}
{{/each}}

Path: form.js

Template.form.helpers({
    student: function() {
        return StudentHistory.find({});
    },
    makeUniqueID: function () {
        return "update-each-" + this._id;
    }
});

Path: Schema.js

StudentHistory = new Mongo.Collection("studentHistory");

StudentHistory.allow({
    insert: function(userId, doc) {
        return !!userId;
    },
    update: function(userId, doc) {
        return !!userId;
    },
    remove: function(userId, doc) {
        return !!userId;
    }
});


var Schemas = {};

Schemas.StudentHistory = new SimpleSchema({
    studentUserId: {
        type: String,
        autoValue: function() { 
            return this.userId; 
        },
        autoform: {
            type: "hidden"
        }
    },
    class: {
        type: String,  
        optional: false    
    }
});

StudentHistory.attachSchema(Schemas.StudentHistory);
1
Please show your schema code for the StudentHistory collection. - Michel Floyd
I've updated the code above - bp123

1 Answers

0
votes

My error was in the template helper. The message disappears when I add the code below.

Template.form.helpers({
    student: function() {
        return StudentHistory.find({"studentUserId": Meteor.userId()});
    }
});