2015-05-24 14 views
1

我想在我的集合中的每个文档中创建一个上传文件数组,名为Modules。我使用下列程序包:使用aldeed在Meteor中插入文件:autoform,cfs:autoform和update-pushArray类型

  • aldeed:自动窗体
  • aldeed:collection2
  • CFS:标准套餐
  • CFS:GridFS的
  • CFS:自动窗体

收藏和Schema(相关部分):

Modules = new Mongo.Collection('modules'); 
Modules.attachSchema (new SimpleSchema({ 
    slides: { 
     type: Array, 
     optional: true 
    }, 
    'slides.$': { 
     type: Object 
    }, 
    'slides.$.fileId': { 
     type: String, 
     label: "Image File" 
    }, 
    'slides.$.time': { 
     type: Number, 
     label: "Time in Seconds" 
    } 
})); 

FileStore = new FS.Collection("fileStore", { 
    stores: [new FS.Store.GridFS("fileStore")] 
}); 

FileStore.allow({ 
    download: function() { 
     return true; 
    }, 
    fetch: null 
}); 

在HTML模板:

{{#autoForm collection="Modules" scope="slides" id="addSlideForm" type="update-pushArray" doc=this}} 
    <fieldset> 
     {{> afQuickField name="time" type="number"}} 
     {{> afQuickField name="fileId" type="cfs-file" collection="fileStore"}} 
    </fieldset> 
    <button type="submit" class="btn btn-primary" >Add Slide</button> 
{{/autoForm}} 

当我按下提交按钮时,如预期的元件推入到阵列。 time值是正确的,但在fileId下只有dummyId而不是来自fileStore的预期_id。

在不涉及嵌套数组的应用程序的其他部分,上传文件按预期工作。在不涉及上传文件的应用程序的其他部分,update-pushArray表单按预期工作。并发症是将两者结合在一起。

我这样做不正确吗?或者是cfs:autoform只与update-pushArray表单类型不兼容?

回答

0

要使用CFS,您的#autoform类型必须是“insert”或“method”,请查看cfs文档以获取更多信息。 希望它有帮助!

+0

欢迎来到Stack Overflow!虽然这可能会在理论上回答这个问题,[这将是更可取的](// meta.stackoverflow.com/q/8259)在这里包括答案的基本部分,并提供参考链接。 – manetsus

相关问题