将来自其他模式的字段添加到 afQuickField
Adding fields from other Schemas to afQuickField
我想使用 {{> afQuickfield name="profile" }}
,它将拉取名称和城市输入字段,并显示用户名的输入框。
当我添加 {{> afQuickfield name="username"}}
时,它会孤独地坐在配置文件 QuickField 的下方。我希望它与配置文件设置一起添加到面板中。
我怎样才能获得一个干净的表单,其中包含配置文件架构中的设置和包含在一个表单中的用户名。
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);
我会使用三个单独的 afQuickfield
作为名称、城市和用户名。他们都可以进入一个自动表单供用户使用:
{{#autoForm collection="User" id="XXX" type="XXX"}}
{{> afQuickfield name="username"}}
{{> afQuickfield name="profile.name"}}
{{> afQuickfield name="profile.city"}}
{{/autoform}}
我想使用 {{> afQuickfield name="profile" }}
,它将拉取名称和城市输入字段,并显示用户名的输入框。
当我添加 {{> afQuickfield name="username"}}
时,它会孤独地坐在配置文件 QuickField 的下方。我希望它与配置文件设置一起添加到面板中。
我怎样才能获得一个干净的表单,其中包含配置文件架构中的设置和包含在一个表单中的用户名。
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);
我会使用三个单独的 afQuickfield
作为名称、城市和用户名。他们都可以进入一个自动表单供用户使用:
{{#autoForm collection="User" id="XXX" type="XXX"}}
{{> afQuickfield name="username"}}
{{> afQuickfield name="profile.name"}}
{{> afQuickfield name="profile.city"}}
{{/autoform}}