我正在使用 Meteor 1.1.0 和 Aldeed:Autoform,我需要在提交期间(或之前)将模板 JS 文件中生成的字符串数组中的值放入 [String] 类型的文档条目中。我怎样才能做到这一点?
最佳答案
解决方案是在 Autoform.hooks 中添加一个 before: Hook ,其中包含一个 insert: 函数,该函数将修改文档条目(为此,必须在架构中定义参数)。示例:
AutoForm.hooks({
'add-form': {
before:{
insert:function(doc){
doc.fileId = '1234; // doc is the data from the form.
return doc; // .fileId is the element we try to modify
}
}
}
});
关于javascript - 如何将 JS 数组添加到 Meteor 自动表单条目中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29393058/