Define User Action
Agile UI Demo v4.0-dev
UI Integration
Arguments
Crud integration
Compared to 1.x versions Crud implementation has became much more lightweight, however you retain all the same functionality and more. Next example shows how you can disable user action (add) entirely, or on per-row basis (delete) and how you could add your own action with a custom trigger button and even a preview.
$country = new Country($owner->getApp()->db);
$country->getUserAction('add')->enabled = false;
$country->getUserAction('delete')->enabled = function (Country $m) {
return $m->id % 2 === 0;
};
$country->addUserAction('mail', [
'appliesTo' => Model\UserAction::APPLIES_TO_SINGLE_RECORD,
'preview' => function (Model $model) {
return 'here is email preview for ' . $model->get('name');
},
'callback' => function (Model $model) {
return 'email sent to ' . $model->get('name');
},
'description' => 'Email testing',
]);
// Register a trigger for mail action in Crud
$owner->getExecutorFactory()->registerTrigger(
ExecutorFactory::TABLE_BUTTON,
[Button::class, null, 'icon' => 'blue mail'],
$country->getUserAction('mail')
);
Crud::addTo($owner, ['ipp' => 5])
->setModel($country, [$country->fieldName()->name, $country->fieldName()->iso]);
Name | ISO | |
---|---|---|
Afghanistan | AF | |
Albania | AL | |
Algeria | DZ | |
American Samoa | AS | |
Andorra | AD |
Edit Country
Email testing