【问题标题】:Autoform users profile page自动形成用户个人资料页面
【发布时间】:2015-04-06 22:08:20
【问题描述】:

我尝试使用自动表单创建用户个人资料页面,但自动表单告诉我“错误:自动表单:当表单类型为插入时,您必须指定一个集合。”

我只有一种方法吗?

请帮我解决问题。

帮手
Template.accountForm.helpers({ userSchema: function () { return Schema.User; } });

模板
<template name="accountForm"> <div class="panel-body"> {{#autoForm schema=userSchema collection=Users id="accountForm" type="insert"}} <fieldset> {{> afObjectField name='profile'}} </fieldset> <button type="submit" class="btn btn-primary">Insert</button> {{/autoForm}} </div> </template>

架构

Schema = {};

Schema.UserProfile = new SimpleSchema({
    lastname: {
        type: String
    }
});

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);

【问题讨论】:

  • 将您的自动表单标签更改为使用type="update"。那应该可以解决它。
  • Tnx 回答但不,不工作
  • 是的,再次出现“错误:AutoForm:当表单类型为插入时,您必须指定一个集合。”

标签: meteor


【解决方案1】:

您不需要辅助函数,只需使用 Meteor.users 对象即可。

{{#autoForm collection='Meteor.users' doc=currentUser type='update' id='accountForm'}}
  {{> afQuickField name='profile'}}
<button type='submit' class="btn btn-primary">Save profile</button>
{{/autoForm}}

【讨论】:

  • 不应该是afObjectField吗?
猜你喜欢
  • 2012-01-24
  • 2020-01-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-01-29
  • 1970-01-01
  • 2016-06-26
  • 2015-03-06
相关资源
最近更新 更多