form() table()
Wrap the table in a form, so inputs, check boxes and selects in its rows post together.
table()->form($action = '', $method = '', $extra = [])Options
| Option | Meaning |
|---|---|
$action | Form action; default url('/@object/@action/@id'), this page. |
$method | Default POST. |
force | Replace the form settings of an earlier call. |
Example
Code
$rows = [
1 => ['id' => 1, 'name' => 'Desk lamp', 'sort' => 10],
2 => ['id' => 2, 'name' => 'Office chair', 'sort' => 20],
];
return table($rows, ['no_pages' => 1])
->form()
->check_box('id', ['desc' => ''])
->text('name')
->input('sort', ['class' => 'input-small'])
->footer_submit('Save order');Notes
- The form opens before the header links and closes after the footer links; an empty table prints no form.
- input(), check_box(), radio_box(), select_box(), data() and icon() call it themselves.
- Handle the post with on_post() or in the action the form posts to, with the usual CSRF check.
See also: table/footer_submit, demo:table/form