2016-03-18 29 views
0

我有一個奇怪的情況。填寫日期字段並單擊autoform-add-item按鈕時,日期數據將消失,但資格字段數據不會。保留日期字段條目的唯一方法是提交表單。有什麼想法嗎。當我添加其他項目時,日期會丟失

路徑:dbExample

"profile": { 
    "CV": { 
     "education": [ 
     { 
      "qualification": "Arts Degree", 
      "startDate": "2009-01-01T00:00:00.000Z", 
      "endDate": "2013-12-01T00:00:00.000Z" 
     }, 
     { 
      "qualification": "Science Degree", 
      "startDate": "2007-01-01T00:00:00.000Z", 
      "endDate": "2008-12-01T00:00:00.000Z" 
     } 
     ] 
    } 
} 

路徑:autoform.html

<template name="education"> 
{{#autoForm collection="Meteor.users" id="educationForm" doc=currentUser type="update"}} 

    {{> afQuickField name='profile.CV.education'}} 
    <button type="submit" class="btn btn-primary submit">Update</button> 
{{/autoForm}} 
</template> 

路徑:Schema.js

Schema.Education = new SimpleSchema({ 
    qualification: { 
     type: String, 
     optional: true  
    }, 
    type: Date, 
    optional: true, 
    autoform: { 
     type: "bootstrap-datepicker", 
     "data-date-autoclose": "true", 
     datePickerOptions: { 
      format: "M yyyy", 
      startView: "months", 
      minViewMode: "months" 
     } 
    }  
}, 
endDate: { 
    type: Date, 
    optional: true, 
    autoform: { 
     type: "bootstrap-datepicker", 
     "data-date-autoclose": "true", 
     datePickerOptions: { 
      format: "M yyyy", 
      startView: "months", 
      minViewMode: "months" 
     } 
    }  
}, 
}); 

    Schema.CV = new SimpleSchema({ 
     education: { 
      type: [Schema.Education], 
      optional: true 
     } 
    }); 

回答

0

我認爲你需要做這樣的事情:

{{#autoForm collection="Meteor.users" id="educationForm" doc=currentUser type="update"}} 
    {{#afEachArrayItem name="profile.CV.education"}} 
     {{> afFieldInput name=this.current.qualification}} 
     {{> afFieldInput name=this.current.startDate}} 
     {{> afFieldInput name=this.current.endDate}} 
    {{/afEachArrayItem}} 
{{/autoForm}} 

默認情況下,Autoform無法處理快速字段的對象數組,因此您需要手動構建它。

+0

感謝您的建議,不能解決問題。我更新了模式以包含我以前缺少的引導信息。我還創建了另一個測試來複制問題,問題消失。我是一個noob,我怎麼去調試這個。控制檯中沒有任何錯誤,所以我有點難倒。 – bp123

+0

好吧,所以它實際上是與aldeed相關的:autoform-b​​s-datepicker如果我刪除類型:「bootstrap-datepicker」並使用chrome瀏覽器日期選擇器,問題就會消失。我需要一個老式瀏覽器的日期選擇器,所以我可以刪除一天,並只有一個月。有沒有辦法來解決這個問題? – bp123

相關問題