Answers.Body: <p>I don't know your requirements, but you could build a "Users Picker" with the <a href="https://github.com/lewisjenkins/craft-lj-dynamicfields" rel="nofollow">Dynamic Fields</a> plugin. You would basically need to do the same in its settings to build your select options as you'd do in a custom plugin.</p>
  
  <p>You get your users with <code>craft.users</code> and then build an array with "label" and "value" keys using the <code>merge</code> filter.</p>
  
  <p>Pass that array into the Dynamic Fields' settings or build the select options with the <code>forms.selectField</code> macro in your own plugin.</p>
  
  <pre><code>{% set users = craft.users.group('clients') %}
  
  {% set userOptions = [] %}
  {% for user in users %}
      {% set userOptions = userOptions|merge([{ label: user.friendlyName, value: user.id }]) %}
  {% endfor %}
  
  {{ forms.selectField({
      label: 'User'|t,
      id: id,
      name: name,
      options: userOptions,
      value: value ? value
  }) }}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-22T15:39:21.953Z
Answers.Text: Thank you this is great, but I was hoping for the native Users picker that spawns a modal. There may be enough options that a select dropdown would be unwieldy. Due to time constraints I'll probably have to just use a separate Users field for now. Thanks again!
Answers.UserDisplayName: Kirk Roberts
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T17:41:34.697Z
Answers.LastActivityDate: 2015-05-21T18:09:32.307Z
Answers.LastEditDate: 2015-05-21T18:09:32.307Z
Answers.UserDisplayName: carlcs
Body: <p>I would like to include a Users picker in a custom field type. Not sure if this is possible and practical.</p>
  
  <p>Do you know how I can accomplish this, or can you point me in the right direction for self-education?</p>
  
  <p>I see there is no users macro in <code>/app/templates/_includes/forms.html</code>, <code>/app/fieldtypes/UsersFieldType.php</code> has almost nothing in it, and I don't know enough about the system yet to know where else to look for ideas.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-21T17:20:34.060Z
Comments.Text: `craft/app/templates/_includes/forms/elementSelect.html` might be what your looking for, if that helps at all.
Comments.UserDisplayName: Douglas McDonald
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-22T15:41:35.707Z
Comments.Text: Very helpful, thanks @DouglasMcDonald! That lead me down a whole new rabbit hole, which quickly filled with water and other mixed metaphors.
Comments.UserDisplayName: Kirk Roberts
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-05-22T21:37:57.540Z
Comments.Text: haha... I know that feeling.
Comments.UserDisplayName: Douglas McDonald
Tags: <users><custom-fieldtype>
Title: How can I include a Users picker in a custom field type?
ThreadText: # How can I include a Users picker in a custom field type?
  
  (Asked by: username_0 on 2015-05-21)
  
  I would like to include a Users picker in a custom field type. Not sure if this is possible and practical.
  
  Do you know how I can accomplish this, or can you point me in the right direction for self-education?
  
  I see there is no users macro in `/app/templates/_includes/forms.html`, `/app/fieldtypes/UsersFieldType.php` has almost nothing in it, and I don't know enough about the system yet to know where else to look for ideas.
  
  **Tags:** users, custom-fieldtype
  
  > **Comments:**
  > **username_1**: `craft/app/templates/_includes/forms/elementSelect.html` might be what your looking for, if that helps at all.  
  > **username_0**: Very helpful, thanks @username_1! That lead me down a whole new rabbit hole, which quickly filled with water and other mixed metaphors.  
  > **username_1**: haha... I know that feeling.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2015-05-21. Score: 2
  
  I don't know your requirements, but you could build a "Users Picker" with the [Dynamic Fields](https://github.com/lewisjenkins/craft-lj-dynamicfields) plugin. You would basically need to do the same in its settings to build your select options as you'd do in a custom plugin.
  
  You get your users with `craft.users` and then build an array with "label" and "value" keys using the `merge` filter.
  
  Pass that array into the Dynamic Fields' settings or build the select options with the `forms.selectField` macro in your own plugin.
  
  ```
  {% set users = craft.users.group('clients') %}
  
  {% set userOptions = [] %}
  {% for user in users %}
      {% set userOptions = userOptions|merge([{ label: user.friendlyName, value: user.id }]) %}
  {% endfor %}
  
  {{ forms.selectField({
      label: 'User'|t,
      id: id,
      name: name,
      options: userOptions,
      value: value ? value
  }) }}
  
  ```
  
  > **Comments:**
  > **username_0**: Thank you this is great, but I was hoping for the native Users picker that spawns a modal. There may be enough options that a select dropdown would be unwieldy. Due to time constraints I'll probably have to just use a separate Users field for now. Thanks again!  
  
  ---
  
  