Skip to main content

Fast Add

fastadd is a table button that lets the user append a new editable row to an inline table, without leaving the current page.

Fast elements are always used with a table. You build a table with magic->get_table($table), bind it to a database table (the detail/child records you want to manage), and enable fastadd through $table['tb_button']. When the user clicks the add button, the framework requests a fresh row from the AJAX handler named in $table['tb_get'] and appends it to the table body.

Use fastadd when:

  • You need to add child/detail rows inline (e.g., branch products, related parties, rate rows).
  • The rows belong to a parent record that is being edited on the same page.
  • You want add + delete row management without a dedicated page.

Enable fastadd on a table

Real example from installment/company_branch.module.php — an inline table of company_branch_product rows. tb_get points to the AJAX handler that builds a new row, and tb_button enables the fastadd button.

{
"tb_id": "tb_company_branch_product",
"tb_get": "add_company_branch_product",
"tb_header": ["product_category", "max_quantity", "allow_quantity_excess_on_edit"],
"tb_button": { "fastadd": true }
}

Fast Add


Behavior

  • Bound to a table: fastadd only works inside a table built with magic->get_table().
  • Row source: Each new row is requested from the AJAX handler named in $table['tb_get'] (handler method = ax_<tb_get>), which returns the row <tr> as $response['data'].
  • Unique names: Inputs are namespaced with a unique data_id (name="field[tb_xxxxx]") so multiple added rows do not collide on submit.
  • Delete icon: Generated rows usually include a fastdelete icon so the user can remove a row again.

Usage Notes

  • Always set tb_get when fastadd is enabled — it names the row-builder AJAX method.
  • Combine with Fast Delete per row, and Full Fast Edit to also load existing rows as editable.
  • Validate CSRF in the AJAX handler ($this->lib->csrf->validate(...)) as shown above.