AccountsTemplate.add/removeField doesn't work


#1

These functions don’t appear to work. I’m trying to make the template display just the username and password field. However, these functions don’t appear to have any effect!

This code is loaded serverside using the new import system.

import { Meteor } from 'meteor/meteor';
import { Accounts } from 'meteor/accounts-base';
import { AccountsTemplates } from 'meteor/useraccounts:core';

const pwd = AccountsTemplates.removeField('password');
AccountsTemplates.removeField('email');

AccountsTemplates.addFields([
  {
    _id: 'username',
    type: 'text',
    displayName: 'username',
    required: true,
    minLength: 5,
  },
  pwd,
]);

I included AccountsTemplates by using the {{> atForm}} inclusion and bound it to a route manually.

Does anyone have any clue why these aren’t working for me?


#2

Have you tried calling it on the client before AccountsTemplates.init() ?


#3

(STDERR) [AccountsTemplates] There is no more need to call AccountsTemplates.init()! Simply remove the call ;-)

When I call this. 0_o


#4

I figured out the problem. This bit turned out to be relevant:

The only other requirement is to make exactly the same calls on both the server and the client. The best thing is to put everything inside a file shared between both. I suggest you use something like lib/config/at_config.js