【问题标题】:Parsing initial values to an ExtraSignUp Fields Meteor将初始值解析为 ExtraSignUp 字段流星
【发布时间】:2016-03-03 23:57:10
【问题描述】:

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

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

【问题讨论】:

  • 你在使用meteor-accounts-ui-bootstrap-3吗?
  • 我正在使用 ian:accounts-ui-bootstrap-3。但文档与meteor-accounts-ui-bootstrap-3 相同。

标签: javascript jquery meteor meteor-accounts


【解决方案1】:

查看那个包中的the implementation of signup,没有办法设置默认值。代码只是在signup() 中创建一个对象,并从表单中获取它可以获取的任何现有值。

【讨论】:

  • 有一个选项。实际上,由于 Accounts.onCreateUser 函数,开发人员可以控制包。
猜你喜欢
  • 1970-01-01
  • 2020-01-01
  • 2019-01-02
  • 1970-01-01
  • 1970-01-01
  • 2017-05-06
  • 1970-01-01
  • 2014-06-20
  • 2015-10-29
相关资源
最近更新 更多