select_box() table()
A drop-down in each row, posting field[value].
table()->select_box($name, $extra = [])Options
| Option | Meaning |
|---|---|
values | Value => text of the options. |
selected | Selected value. |
name | Posted name; default the field name, [value] appended unless it holds a [. |
(html options) | Every option of html()->select_box(). |
Example
Code
$rows = [
1 => ['id' => 1, 'name' => 'Desk lamp', 'status' => 'new'],
2 => ['id' => 2, 'name' => 'Office chair', 'status' => 'sent'],
];
$statuses = ['new' => 'New', 'paid' => 'Paid', 'sent' => 'Sent'];
return table($rows, ['no_pages' => 1])
->text('name')
->select_box('id', ['values' => $statuses, 'selected' => 'paid', 'name' => 'status', 'desc' => 'Status']);Notes
- The field value of the row is the key of the posted name (here
status[1]);selectedis the same for every row. For a per-row selection render the select in a func() column. - Ids are
selectbox_<value>. It calls form().
See also: html/select_box, demo:table/form