将初始值解析为 ExtraSignUp 字段流星

Parsing initial values to an ExtraSignUp Fields Meteor

本文关键字:ExtraSignUp 字段 流星      更新时间:2023-09-26

我正在尝试为用户注册添加一个隐藏字段。问题不在于字段本身,而在于它的价值。我想将其解析为默认值。这是我的代码:

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; 
});

查看该包中注册的实现,无法设置默认值。 代码只是在 signup() 中创建一个对象,并从表单中获取任何现有值。