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 :(得分: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无法使用快速字段默认处理对象数组,因此您需要手动构建它。