Reputation: 2378
I'm using accounts-ui for the login system. I want to a create a profile form which I've got displaying using autoform. When I try to submit the form the params are passed in the URL and the page refreshes but nothing is saved to the collection.
Any ideas?
Here's my schema (I've also tried just using a UserProfile schema but that didn't work)
Schema = {};
Schema.UserProfile = new SimpleSchema({
firstName: {
type: String,
regEx: /^[a-zA-Z-]{2,25}$/
},
lastName: {
type: String,
regEx: /^[a-zA-Z]{2,25}$/
},
gender: {
type: String,
allowedValues: ['Male', 'Female']
},
bio: {
type: String,
},
avatar: {
type: String,
},
pinCode: {
type: Number,
min: 7,
max: 7
},
phoneNumber: {
type: Number,
min: 9,
max: 10
}
});
Schema.User = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
},
createdAt: {
type: Date
},
profile: {
type: Schema.UserProfile,
},
services: {
type: Object,
optional: true,
blackbox: false
}
});
Meteor.users.attachSchema(Schema.User);
Template.signupForm.helpers({
users: function () {
return Meteor.users;
},
userSchema: function () {
return Schema.User;
}
});
/* as an idea ....
Template.signupForm.editingDoc = function () {
return Meteor.users.find({_id: Meteor.userId()});
};
*/
//template
<template name="signupForm">
<div class="panel-body">
{{#autoForm schema=userSchema id="signupForm" doc=editingDoc type="update"}}
<fieldset>
{{> afObjectField name='profile'}}
</fieldset>
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
</div>
</template>
Upvotes: 2
Views: 566
Reputation: 195
This is really late but if anyone need this, the issue you where having is you never gave it the user collection:
{{#autoForm
collection='Meteor.users' //this was your issue
id="signupForm"
doc=editingDoc
type="update"
}}
If you wanted to you could even limit the form to just the profile with:
{{#autoForm
collection='Meteor.users'
schema="Schema.UserProfile" //both collection & schema will render schema
id="signupForm"
doc=editingDoc
type="update"
}}
Upvotes: 3