将初始值解析为 ExtraSignUp 字段 Meteor
Parsing initial values to an ExtraSignUp Fields Meteor
我正在尝试为用户注册添加一个隐藏字段。问题不在于该领域本身,而在于它的价值。我想将其解析为默认值。这是我的代码:
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,
}]
});
I want to add the value to the field 'status'.
Actually, I found the answer. The option is the following code in the
server folder:
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
user.profile = options.profile;
}
user.profile.status = "sth";
return user;
});
查看那个包中的the implementation of signup,没有办法设置默认值。该代码只是在 signup()
中创建一个对象,并尽可能从表单中获取任何现有值。
我正在尝试为用户注册添加一个隐藏字段。问题不在于该领域本身,而在于它的价值。我想将其解析为默认值。这是我的代码:
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,
}]
});
I want to add the value to the field 'status'.
Actually, I found the answer. The option is the following code in the server folder:
Accounts.onCreateUser(function(options, user) {
if (options.profile) {
user.profile = options.profile;
}
user.profile.status = "sth";
return user;
});
查看那个包中的the implementation of signup,没有办法设置默认值。该代码只是在 signup()
中创建一个对象,并尽可能从表单中获取任何现有值。