user() table()

Show user ids as links with the login (or name, email, phone) of each user, loaded in one query.

table()->user($name = '', $extra = [])

Options

OptionMeaning
linkLink of each user; default url_admin('/members/edit/%d').
nameField holding the ids (when the first argument is the options array).

Example

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

Code

$rows = [
    1 => ['id' => 1, 'title' => 'First post', 'user_id' => 1],
    2 => ['id' => 2, 'title' => 'Shared draft', 'user_id' => '1,2'],
];
return table($rows, ['no_pages' => 1])
    ->text('title')
    ->user('user_id', ['desc' => 'Author']);

Notes

  • The field may hold one id, an array of ids or a comma-separated list; an unknown id prints the id.
  • Designed for the admin: it reads the user table.

See also: table/admin, form/user_info