User Interface
Agile UI Demo v5.0-dev
Interactivity
Business Model
Persistence
Once your model is defined, it can be re-used later with any generic view:
session_start();
$model = new DemoInvoice(new Persistence\Array_($_SESSION['atk4_ui_intro_demo'] ?? []));
$model->onHook(Model::HOOK_AFTER_SAVE, static function (Model $model) {
$_SESSION['atk4_ui_intro_demo'][$model->getId()] = (clone $model->getModel())->addCondition($model->idField, $model->getId())->export(null, null, false)[$model->getId()];
});
Header::addTo($owner, ['Record display in Card View using model data.']);
$model = $model->tryLoad(1);
if ($model !== null) {
Card::addTo($owner, ['useLabel' => true])
->setModel($model);
} else {
Message::addTo($owner, ['Empty record.']);
}
Record display in Card View using model data.
Re-use of your Business Model code, generic and interactive views and principles of composition and a simple PHP code offers a most efficient way of constructing Web Applications.