Search code examples
meteorionic-frameworkmeteoric

Rearrange field using meteor-useraccount ionic in Meteor


I am doing signUp for my app using useraccounts:ionic package, which uses useraccounts:core internally.

I created the form with three field Full Name, Email & Password. In default signUp form Full Name field is not there, So, I added like this,

AccountsTemplates.addField({
    _id: 'fullname',
    type: 'text',
    displayName: "Full Name",
    required: true
});

And i don't want Confirm Password. So, removed it.

AccountsTemplates.configure({
    confirmPassword: false,
    ....
});

But Now i what to rearrange Field. i.e.

 |=====================|
 |     Full Name       |
 |=====================|
 |       Email         |
 |=====================|
 |      Password       |
 |=====================|

After going through the meteor-useraccounts/core Guide.

Here is my code:

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

AccountsTemplates.addField([
    {
        _id: 'fullname',
        type: 'text',
        displayName: "Full Name",
        required: true
    },
    email,
    pwd
]);

It is throwing me this error:

Exception in template helper: TypeError: Cannot read property 'form' of undefined

Here is my code at MeteorPad


Solution

  • Try in the following order

    AccountsTemplates.addField({
      _id: 'fullname',
      type: 'text',
      displayName: "Full name",
      placeholder: {
        signUp: "Full name"
      },
      required: true,
      minLength: 1,
      trim: true
    });
    
    var email = AccountsTemplates.removeField('email');
    
    AccountsTemplates.addField(email);
    
    var password = AccountsTemplates.removeField('password');
    
    AccountsTemplates.addField(password);
    

    This is working for me