我有一个表格供人们创建一个事件,以后会有成员,但不是在创建时.创建事件时,不应添加任何成员,因此autoform不显示任何成员字段:
createEvent.jade
template(name="createEvent")
+quickForm(collection="Events" id="createEventForm" type="insert" fields="name,description,location")
Run Code Online (Sandbox Code Playgroud)
对于要提交的表单,我相信我必须确保Events
集合中所有必填字段都有值,即使不是表单.表单将不会提交(提交按钮无效,我正在检查minimongol以确保没有记录条目)即使我已经尝试添加defaultValue:
crew: {
type: [String],
label: "Crew",
defaultValue: ""
},
Run Code Online (Sandbox Code Playgroud)
和autoValue将创建者添加为成员:
crew: {
type: [String],
label: "Crew",
autoValue: function() {
return this.userId;
},
},
Run Code Online (Sandbox Code Playgroud)
我在一分钟前遇到这个问题,默认情况下没有表单字段设置事件创建者,现在它可以工作:
host: {
type: String,
label: "Host",
autoValue: function() {
return this.userId;
},
},
Run Code Online (Sandbox Code Playgroud)
但我不能得到这个基于数组的默认值.我也试过defaultValue: "['']"
了一些其他人.坚持到现在,请帮忙..
我希望能够从用户列表中选择多个用户.
我是用户collection2
,simple-schema
而且autoform
.
我想为此做一个简单的quickForm.这是我的简单架构:
Schemas.Item = new SimpleSchema({
name: {
type: String,
label: "Name",
max: 100
},
userIds: {
type: [String],
regEx: SimpleSchema.RegEx.Id
}
});
Run Code Online (Sandbox Code Playgroud)
看一下autoform docs,我注意到我想要一个select视图,所以我需要传入选项.
我希望能够在我的架构中做到这一点!
userIds: {
type: [String],
regEx: SimpleSchema.RegEx.Id
options: function() {
// return users with {value:_id, label:username}
}
}
Run Code Online (Sandbox Code Playgroud)
否则,我必须生成一个带有quickFormFields的模板,只是为了传递选项.
只是为了堆积东西,不应该有任何重复的userIds ...
谢谢你的帮助
我刚刚将Meteor collection2添加到我的应用程序中.在服务器文件夹的文件中,我添加了代码:
Schema = {}
Schema.User = new SimpleSchema(
_id:
type: String
regEx: SimpleSchema.RegEx.Id
username:
type: String
regEx: /^[a-z0-9A-Z_]{3,15}$/
emails:
type: [Object]
optional: true
"emails.$.address":
type: String
regEx: SimpleSchema.RegEx.Email
"emails.$.verified":
type: Boolean
createdAt:
type: Date
)
Meteor.users.attachSchema Schema.User
Run Code Online (Sandbox Code Playgroud)
它正在崩溃我的应用程序错误:
W20140907-02:06:32.777(-4)? (STDERR) /Users/Nearpoint/.meteor/packages/meteor-tool/.1.0.25.2ltu8i++os.osx.x86_64+web.browser+web.cordova/meteor-tool-os.osx.x86_64/dev_bundle/lib/node_modules/fibers/future.js:173
W20140907-02:06:32.777(-4)? (STDERR) throw(ex);
W20140907-02:06:32.777(-4)? (STDERR) ^
W20140907-02:06:32.792(-4)? (STDERR) Error: undefined is not allowed by the schema
W20140907-02:06:32.792(-4)? (STDERR) at getErrorObject (packages/aldeed:collection2/collection2.js:489)
W20140907-02:06:32.792(-4)? (STDERR) at doValidate (packages/aldeed:collection2/collection2.js:472)
W20140907-02:06:32.792(-4)? (STDERR) at Meteor.Collection.(anonymous function) [as update] (packages/aldeed:collection2/collection2.js:282)
W20140907-02:06:32.792(-4)? (STDERR) at UserConnections.upsert.$set.ipAddr …
Run Code Online (Sandbox Code Playgroud) 我正在使用如下所示的collection2包:https://github.com/aldeed/meteor-collection2
我已经设置了一个简单的模式,其中只有email
一个非可选值,但尽管这样简单,每次声称"需要电子邮件"时验证都会失败.
我的架构:
Schema.UserProfile = new SimpleSchema({
firstName: {
type: String,
regEx: /^[a-zA-Z-]{2,25}$/,
optional: true
},
lastName: {
type: String,
regEx: /^[a-zA-Z]{2,25}$/,
optional: true
},
birthday: {
type: Date,
optional: true
},
likes: {
type: [String],
optional: true
}
})
Schema.User = new SimpleSchema({
username: {
type: String,
regEx: /^[a-z0-9A-Z_]{3,15}$/,
optional: true
},
email: {
type: String,
regEx: SimpleSchema.RegEx.Email
},
verified: {
type: Boolean,
optional: true
},
createdAt: {
type: Date,
optional: true
},
profile: …
Run Code Online (Sandbox Code Playgroud) 我使用Simple Schema设置了我的集合:
SubLinkSchema = new SimpleSchema({
name: {
type: String,
label: 'Link Name',
unique: false
},
link: {
type: String,
regEx: SimpleSchema.RegEx.Url,
label: 'Custom Link',
optional: true,
autoform: {
class: 'sub-custom-link'
}
}
});
LinkSchema = new SimpleSchema({
name: {
type: String,
label: 'Link Name',
unique: false
},
link: {
type: String,
regEx: SimpleSchema.RegEx.Url,
label: 'Custom Link',
optional: true,
autoform: {
class: 'main-custom-link'
}
},
subLinks: {
optional: true,
label: 'Sub Links',
unique: false,
type: [SubLinkSchema]
}
});
Run Code Online (Sandbox Code Playgroud)
在这里,问题是,子链接没有获得ID.很难在没有id的情况下更新它们.那么,我如何为每个子链接(嵌入文档)生成唯一ID?
我正在尝试使用Meteor Collection2构建一个集合模式.
我的集合可能的架构是:
{
items: {
id: Meteor.ObjectID
title: String,
Desc: String,
createdAt: new Date(),
creator: String,
invitedUsers: [String],
items2: [{
id: String,
pos: Number,
dur: Number,
startTime: Number,
endTime: Number,
duration: Number
items3: [{
id: String,
itemtype: String,
style: String,
items4: [{
id: String,
position: Number,
dome: String
}]
}]
}]
}
}
Run Code Online (Sandbox Code Playgroud)
那么我怎样才能最好地使用上面的嵌套模式构建Collection2集合,以及在其上执行插入,更新和删除查询的最佳方法.
更新:
现在正如Andrei Karpushonak所建议的那样,这就是我所拥有的:
Item4 = new SimpleSchema({
position: {
type: Number
},
dome: {
type: String
}
});
Item3 = new SimpleSchema({
itemtype: {
type: …
Run Code Online (Sandbox Code Playgroud)