javascriptmeteormeteor-autoform

AutoValues from Session.get()


I have a simple schema in other to use autoform in meteor. I am having problem with this field in my Schema. When I submit the form it does nothing. How can I set and insert the value of my id_master in the array with autoValues through the Session.get()?

master_id: {
    type: [String],
    label: "id_master",
    autoValue: function(){
    if( this.isInsert ) {
        var x =Session.get('id_master'); 
        console.log(x);//returns the value of id_master
       return [x]
        }
    }, 
    autoform:{
        type: "hidden"
    }

},

I'm using autoForm :

{{> quickForm collection="Hitos" id="insertHitosForm" type="insert" class="new-hito-form"}}

And I have allowed Inserting :

Hitos.allow({
        insert: function(userId, doc){
            //you are allowed to insert Hitos if userid exist
            return !!userId;

        }
});

Solution

  • According to the documentation, you shouldn't need to, but have you tried using clean()?

    AutoForm.hooks({
      insertHitosForm: {
        onSubmit: function (doc) {
          Hitos.clean(doc);
          console.log("Hitos doc with auto values", doc);
          this.done();
          return false;
        }
      }
    });