Search code examples
meteormeteor-autoform

Adding fields from other Schemas to afQuickField


I want to use {{> afQuickfield name="profile" }} which will pull the name and city input fields and also have it display an input box for the username.

When I add {{> afQuickfield name="username"}} it will just sit lonely below outside the profile QuickField. I want it to be added to the panel along with the profile settings.

How can I achieve a clean Form which has both the Settings in the profile Schema and the username wrapped up in one Form.

Schemas.UserProfile = new SimpleSchema({
  name: {
    type: String,
    optional: true
  },
  city: {
    type: String,
    optional: true
  }
});

Schemas.User = new SimpleSchema({
  username: {
    type: String,
    regEx: /^[a-z0-9A-Z_]{3,15}$/,
    optional: true
  },

  (...)

  profile: {
    type: Schemas.UserProfile
}});

Meteor.users.attachSchema(Schemas.User);

Solution

  • I would use three separate afQuickfield for name, city, and username. They can all go in one autoform for User:

    {{#autoForm collection="User" id="XXX" type="XXX"}}
        {{> afQuickfield name="username"}}
        {{> afQuickfield name="profile.name"}}
        {{> afQuickfield name="profile.city"}}
    {{/autoform}}