ozcoro
1
Good day,
I am trying to add as an option all the users in the Aldeed Autoform but I think my syntax is wrong.
I have the following as part of the schema
Tasks.attachSchema(new SimpleSchema({
task: {
type: String,
label: "Task",
max: 20
},
project: {
type: String,
label: "Project"
},
date:{
type:Date,
label:"Date"
},
checked:{
type:Boolean,
label:"Checked",
optional : true
},
users:{
type:String,
label:"Users",
optional: true,
autoform:{
type: "select-multiple",
options: function(){
return Meteor.users.find();
}
}
}
}));
What is wrong?
corvid
2
This returns a cursor. Use:
Meteor.users.find().map((doc) => doc._id);
ozcoro
3
Ok, Ive tried that and the Label doesnt appear in the form, or the selector
Do I have to change the HTML as well
Curren HTML
{{#autoForm collection="Tasks" id="insertTaskForm" type="insert"}}
{{> afQuickField name='task'}}
{{> afQuickField name='project'}}
{{> afQuickField name='date'}}
{{> afQuickField name='user'}}
<button type="submit" class="btn btn-primary">Insert</button>
{{/autoForm}}
Current JS in schema
user:{
type:String,
label:"Users",
optional: true,
autoform:{
type: "select",
options: function(){
return Meteor.users.find().map((doc) = doc._id);
}
}
}
corvid
4
user: {
type: [String],
label: 'Users',
optional: true,
autoform: {
options: function () {
return Meteor.users.find().map((doc) => ({
label: doc.username,
value: doc._id
}))
}
}
}
Make sure you’re subscribed to users too
1 Like
ozcoro
5
Thank you it worked great