auto() form()

Build a form from the columns of a DB table and fill it with one row: the field kind follows the column type.

form()->auto($table = '', $id = '', $params = [])

Options

OptionMeaning
$table, $idTable and row id; id becomes an info row, login / email / phone / active their fields, enum / set radios, dates datetime_select(), text textarea(), numbers number() / float().
db, links_addDatabase object; a string added to the form links.

Example

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

Code

return form()->auto(db('static_pages'), 1);

Notes

  • Without a table, a form made from an SQL string shows each value as a container row.
  • A Save and back button is added. Handy for admin prototypes; a real form names its fields.

See also: table/auto, demo:form/auto