简体   繁体   English

Meteor AutoForm添加用户以选择

[英]Meteor AutoForm adding users to select

I know I am close on this, but just cant seem to sort out what I am missing. 我知道我对此很了解,但是似乎无法理清我所缺少的东西。

I am trying to add all users as options to a select in an autoform quickform. 我试图将所有用户作为选项添加到自动表单快速表单中的选择中。 I was able to get it working with another collection, but when I use the same code for the users the value shows up as the _id but I cannot get the label to return. 我能够使它与另一个集合一起使用,但是当我为用户使用相同的代码时,该值显示为_id,但是我无法返回标签。

Here is the structure of my users: 这是我的用户的结构:

 { "_id": "s3EYXXK5N8NExHrke", "emails": [{ "address": "admin@gmail.com", "verified": false }], "profile": { "firstName": "Joe", "lastName": "Smuck", "licenseNumber": "1234567", "accountType": "administrator" }, "roles": [ "administrator" ], "createdAt": "2016-12-02T21:51:11.844Z", "services": { "password": { "bcrypt": "$2a$10$NheMU2x/8RvcMxNHeWxbQOpHlWAQmopvk3KrMG9oo5ruTir2ARf8W" }, "resume": { "loginTokens": [{ "when": "2016-12-02T21:51:11.948Z", "hashedToken": "8PktpX6kqK6yM+LMrqRaoqXCbwYG6gdO7MH9V/Th/dI=" }, { "when": "2016-12-03T03:01:06.600Z", "hashedToken": "ihn93xaN6rE8fvwBHZ3p8H6z0T7o7WChQoqD4dlkSpw=" }, { "when": "2016-12-05T14:37:41.147Z", "hashedToken": "7QE7HxcmDrZPFI3Omn5c1o73pMa3XzOBj3RbquCmo6U=" }] } } } 

I am trying to print the firstName to the select. 我试图将名字打印到选择。 Here is the schema I have now: 这是我现在拥有的架构:

  inspector: { type: String, label: "Inspector", autoform: { firstOption: 'Choose an Inspector', options: function() { return Meteor.users.find({}, { sort: { profile: 1, firstName: 1 } }).map(function(c) { return { label: c.firstName, value: c._id }; }); } } }, 

I would appreciate any help someone can offer! 我将不胜感激有人能提供的任何帮助!

To tie this off it should have been: 为了解决这个问题,它应该是:

  inspector: { type: String, label: "Inspector", autoform: { firstOption: 'Choose an Inspector', options: function() { return Meteor.users.find({}, { sort: { profile: 1, firstName: 1 } }).map(function(c) { return { label: c.profile.firstName, value: c._id }; }); } } }, 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM