2016-03-01 21 views
0

我想爲用戶註冊添加一個隱藏的字段。問題不在於領域本身,而在於其價值。我想解析它爲默認值。這是我的代碼:解析初始值到一個ExtraSignUp字段流星

Accounts.ui.config({ 
    requestPermissions: {}, 
    extraSignupFields: [{ 
     fieldName: 'name', 
     fieldLabel: 'Name', 
     inputType: 'text', 
     visible: true, 
     validate: function(value, errorFunction) { 
      if (!value) { 
      errorFunction("Please write your first name"); 
      return false; 
      } else { 
      return true; 
      } 
     } 
    },{ 
     fieldName: 'status', 
     fieldLabel: 'Status', 
     inputType: 'text', 
     value: 'somevalue', 
     visible: false, 
    }] 
}); 

我要值添加到字段「狀態」。

其實我找到了答案。該選項在 服務器文件夾下面的代碼:

Accounts.onCreateUser(function(options, user) { 
    if (options.profile) { 
     user.profile = options.profile; 
    } 
    user.profile.status = "sth"; 
    return user; 
}); 
+0

你使用meteor-accounts-ui-bootstrap-3嗎? –

+0

我正在使用ian:accounts-ui-bootstrap-3。但是文檔與meteor-accounts-ui-bootstrap-3相同。 – StefanL19

回答

0

綜觀該包the implementation of signup,沒有辦法設置默認值。該代碼只是在signup()中創建一個對象,並從其可能的形式中抓取現有值。

+0

有一個選項。事實上,事實證明,由於使用了Accounts.onCreateUser函數,開發人員可以控制軟件包。 – StefanL19