Stefan Hayden

Alt + Shift + Ctrl + K

User Profile Edit with Autoform and SimpleSchema in Meteor JS

The steps to creating a form with autoform for editing user profile information are simple but not obvious when trying to tie everything together for the first time.

The first step is the set up the Schema. You need to set it correctly for the user data but the profile object is free form where you can add anything you want. Remember that all the things in the profile object are editable by the user. After you craete the schema be sure to attach it to the users collection.

Next you just need to create the form. The autoform quickform helper will spit out a form for all the user data, most of which you probably don’t want the user to be editing. Instead we can easily just show the fields we want to let users edit:

And that’s it. In theĀ autoForm helper the collection accepts either a template helper (no quotes) or a global variable (quotes). For users you need to pass in the “Meteor.users” collection. To set what data to load the doc attribute needs an object with a _id property which the currentUser helper has.

1 Comment
Gravatar

Very helpful. I’m just a week in Meteor, and this saved me a lot of headache. A pretty simple process but was hard to figure out. Thanks

Feed Icon Comment Feed

Post a Comment