2016-08-07 80 views
0

獲得字段的值我有以下模式:流星 - 帶自動窗體和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一起保存。

回答

0

好吧,我不得不使用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' 
     } 
    } 
});