User Interface
Business Model

One major benefit of Server Side Rendered applications is ability to directly interact with data. In other applications you may need to manually process data but in Agile Toolkit we use data mapping framework.

/* Showing Class definition.
class DemoInvoice extends \Atk4\Data\Model
    public $title_field = 'reference';

    protected function init(): void

        $this->addField('date', ['type' => 'date']);

$model = new \Atk4\Ui\Demos\DemoInvoice(new \Atk4\Data\Persistence\Array_($_SESSION['x'] ?? []), ['dateFormat' => $owner->getApp()->ui_persistence->date_format]);
$model->onHook(\Atk4\Data\Model::HOOK_AFTER_SAVE, function ($model) {
    $_SESSION['x'][$model->getId()] = $model->get();

Header::addTo($owner, ['Set invoice data:']);
$form = \Atk4\Ui\Form::addTo($owner);

if (!$model->loaded()) {
    // set default data
        'id' => 1,
        'reference' => 'Inv-' . random_int(1000, 9999),
        'date' => date($owner->getApp()->ui_persistence->date_format),

$form->onSubmit(function ($f) {

    return new JsToast('Saved!');

\Atk4\Ui\View::addTo($owner, ['ui' => 'divider']);
Set invoice data:

This code shows you a combination of 3 objects:

  • Form - a generic view that can display and handle any form
  • Model - defines fields for a business object
  • Persistence - creates a persistent storage location for the data

All three are combined by "setModel()" function and that is consistent throughout all the views.