Define User Action
UI Integration
CRUD integration
What are Actions?

Since the early version ATK UI was about building generic UI capable of automatically read information about model Fields and visualising them correctly. Version 2.0 introduces support for "Actions" which can be declared in Data layer and can use generic UI for visualising and triggering. Models of Agile Data has always supported 3 basic actions: "save" (for new and existing records) and "delete". Historically any other interaction required tinkering with UI layer. Now ATK implements a generic support for arbitrary actions and then re-implements "save", "delete" and "add" on top.

This enables developer to easily add more actions in the Data layers and have the rest of ATK recognise and respect those actions. Actions can be added into the model just like you are adding fields:

$country = new \atk4\ui\demo\CountryLock($app->db);


Once defied - actions will be visualised in the Form, Grid, CRUD and CardDeck. Additionally add-ons will recognise your actions - for example 'Login' add-on introduces ACL system capable of enabling/disabling fields or actions on per-user basis.

Any actions you define will automatically appear in the UI. This is consistent with your field definitions. You can also "disable" or mark actions as "system". When action is executed, the response will appear to the user as a toast message, but this can also be customised.

$country = new \atk4\ui\demo\CountryLock($app->db);

$country->addUserAction('send_message', function() {
    return 'sent';

$card = \atk4\ui\Card::addTo($app);
$card->setModel($country, ['iso']);
Send Message