user_select_box() form()

A Select2 field that searches the site users through the form API endpoint; shows login and id.

form()->user_select_box($name, $values = null, $extra = [], $replace = [])

Options

OptionMeaning
$valuesPreset id => label; the stored ids are labelled from the user table.
(select2 options)Every option of select2_box().

Example

This example reads the database: it runs in the admin docs only.

Code

return form(['user_id' => 1])->user_select_box('user_id', null, ['desc' => 'Customer']);

Notes

  • Designed for the admin: it reads the user table.

See also: form/select2_box, table/user