addSubmitButton() adds custom buttons near the form submit button.
Purpose
addSubmitButton() adds custom buttons near the form submit button. It lets a controller customize Aksara Core behavior while keeping the request inside the built-in CRUD, rendering, permission, validation, and response pipeline.
When to Use
Use it when the default generated interface needs extra controls, actions, filters, or layout behavior.
Reference
addSubmitButton(?string $name, ?string $value, string $label, ?string $class = null, ?string $icon = null, ?string $attribution = null)
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
$name | ?string | Yes | - | Submitted button name. |
$value | ?string | Yes | - | Value assigned to the given key or field. |
$label | string | Yes | - | Human-readable label. |
$class | ?string | No | null | CSS class list. |
$icon | ?string | No | null | Icon class. |
$attribution | ?string | No | null | Additional raw attributes for the generated element. |
Return Value
static
Returns the current controller instance so it can be chained with other Core methods.
Behavior
addSubmitButton() stores UI configuration for the generated interface. The renderer reads that configuration later and places the control in the correct table, toolbar, filter, grid, or form location.
Basic Usage
$this->addSubmitButton('save_continue', '1', phrase('Save and Continue'), 'btn btn-outline-primary', 'mdi mdi-content-save');
return $this->render('orders');
Advanced Usage
$this->addToolbar('orders/report', phrase('Report'), 'btn btn-outline-primary', 'mdi mdi-chart-bar')
->addButton('orders/read', phrase('View'), 'btn btn-sm btn-outline-secondary', 'mdi mdi-eye', ['order_id' => 'order_id']);
Complete Example
namespace Modules\Orders\Controllers;
use Aksara\Laboratory\Core;
class Orders extends Core
{
public function index()
{
$this->setTitle(phrase('Orders'))
->addSubmitButton('save_continue', '1', phrase('Save and Continue'), 'btn btn-outline-primary', 'mdi mdi-content-save');
return $this->render('orders');
}
}
Result
The generated interface includes or changes the configured control without requiring a custom view.
Notes
- This method is chainable and returns the current controller instance.
- Use
phrase()for visible labels so the interface remains translatable. - Action parameters can reference row fields so generated buttons point to the current record.
Common Mistakes
- Hard-coding labels that should be translated with
phrase(). - Forgetting row parameters for actions that need the current record ID.
