I want to create a couple of users quickly and i figured autoform would be of help.
This is my schema
Schema = {};
Schema.UserProfile = new SimpleSchema({
schoolname: {
label: "School Name",
optional: false,
type: String
},
schooldescription: {
label: "School Description",
optional: false,
type: String
},
schoollocation: {
label: "School Location",
optional: false,
type: String
},
schoollogo : {
label: "School Logo",
optional: false,
type: String
},
schooltelephonenumber: {
label: "School Telephone Number",
optional: false,
type: String
}
});
Schema.User = new SimpleSchema({
email: {
type: String,
// For accounts-password, either emails or username is required, but not both. It is OK to make this
// optional here because the accounts-password package does its own validation.
// Third-party login packages may not require either. Adjust this schema as necessary for your usage.
regEx: SimpleSchema.RegEx.Email
},
password: {
type: String,
},
createdAt: {
type: Date
},
profile: {
type: Schema.UserProfile,
optional: true
}
});
Meteor.users.attachSchema(Schema.User);
In my html i have this
{{ #autoForm schema="Schema.User" id="usercreation" collection ="Meteor.users" type="method" meteormethod="usercreation" }}
<fieldset>
<legend>Create an account</legend>
{{> afQuickField name='email' label='Email' }}
{{> afQuickField name='password' label='Password' }}
{{> afQuickField name='schoolname' label='School Name' }}
{{> afQuickField name='schooldescription' label='School Description' }}
{{> afQuickField name='schoollocation' label='School Location' }}
{{> afQuickField name='schoollogo' label='School Logo' }}
{{> afQuickField name='schooltelephonenumber' label='School Telephone Number' }}
</fieldset>
<input type="submit">
{{ /autoForm }}
This is my method
'usercreation': function(params){
Accounts.createUser({
email: post.params.email,
password: params.password,
profile: {
schoolname: params.schoolname,
schooldescription: params.schooldescription,
schoollocation: params.schoollocation,
schoollogo: params.schoollogo,
schooltelephonenumber: params.schooltelephonenumber
}
});
},
The form displayed only shows email and password and not other fields of the form. The code does not create a user too.