我有一个声明为:
的模式JobSchema = new SimpleSchema({
responsibilities: {
type: [String],
optional: true
},
'responsibilities.$': {
min: 2,
autoform: {
afFieldInput: {
class: 'form-control'
},
placeholder: 'E.g. "Build tools according to specifications"'
}
}
});
我还有一个UI助手声明为:
Template.registerHelper('currentFieldValue', function (fieldName) {
return AutoForm.getFieldValue('insertJobForm', fieldName) || '';
});
我有一个模板,我使用这个帮助器来生成表单预览。除了数组之外,它对所有领域都有魅力。什么都没有呈现。有什么想法吗?
{{# if currentFieldValue "responsibilities"}}
<h3>Responsibilities</h3>
{{{currentFieldValue "responsibilities"}}}
{{/if}}
答案 0 :(得分:0)
快速而肮脏的解决方法:
<强> job_create.js 强>
Template.jobCreate.helpers({
responsibilities: function() {
var formData = AutoForm.getFormValues('insertJobForm');
return formData.insertDoc.responsibilities || [];
}
});
<强> job_create.html 强>
{{# if responsibilities}}
<h3>Responsibilities</h3>
{{responsibilities}}
{{/if}}