tpl_row() table()
Add a column by the name of its method, the form a template or a config array can hold.
table()->tpl_row($type = 'input', $name = '', $desc = '', $extra = [])Example
| Product | Added |
|---|---|
| Desk lamp | 11/02/26 |
Code
$rows = [1 => ['id' => 1, 'name' => 'Desk lamp', 'add_date' => '2026-11-02 09:15:00']];
$columns = [['text', 'name', 'Product'], ['date', 'add_date', 'Added']];
$table = table($rows, ['no_pages' => 1]);
foreach ($columns as [$type, $name, $desc]) {
$table->tpl_row($type, $name, $desc);
}
return $table;Notes
- It calls
$type($name, $desc, $extra): use it with the column methods that take those three arguments (text(), date(), stars()). $typemust be a column method name from your code, never request data.
See also: form/tpl_row