[英]AutoValues from Session.get()
I have a simple schema in other to use autoform
in meteor
. 我在其他autoform
有一个简单的架构,可以在meteor
使用autoform
。 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()
? 如何通过Session.get()
使用autoValues在数组中设置和插入id_master
的值?
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 : 我正在使用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;
}
});
According to the documentation, you shouldn't need to, but have you tried using clean()
? 根据文档,您不需要,但是是否尝试使用clean()
?
AutoForm.hooks({
insertHitosForm: {
onSubmit: function (doc) {
Hitos.clean(doc);
console.log("Hitos doc with auto values", doc);
this.done();
return false;
}
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.