流星 - 带自动窗体和Collection2
问题描述:
获得字段的值我有以下模式:流星 - 带自动窗体和Collection2
GuestSchema = new SimpleSchema({
name: {
type: String,
label: 'Name'
}
code: {
type: String,
label: 'Code',
autoValue: function(){
return AutoForm.getFieldValue('name', 'insertGuestForm');
},
autoform: {
type: 'hidden'
}
}
});
<template name="NewGuest">
<div class="new-guest">
{{> quickForm collection="Guests" id="insertGuestForm" type="insert" class="new-guest-form"}}
</div>
</template>
但AutoForm.getFieldValue
无法按预期工作。我想获得name
的字段值,并将其与我的数据库中的属性code
一起保存。
答
好吧,我不得不使用this.field("name");
GuestSchema = new SimpleSchema({
name: {
type: String,
label: 'Name'
}
code: {
type: String,
label: 'Code',
autoValue: function(){
var content = this.field("name");
return content.value;
},
autoform: {
type: 'hidden'
}
}
});