CoolCMS API

RowAction
in package

Action over one row (buttons in the last column). Two modes:

  • link to a presenter action: ->setLink(':Admin:System:Page:edit', ['id' => 'id']) (URL parameter => entity property path),
  • component signal: ->setSignal('delete') calls handle<Signal>(int $id) on the grid (the built-in delete deletes through the manager).

Plain configuration object: RowAction::create('edit')->setLabel(…)->….

Table of Contents

Constants

TYPE_LINK  : mixed = 'link'
TYPE_SIGNAL  : mixed = 'signal'

Properties

$confirm  : string|null
$confirmTitle  : string|null
$confirmYes  : string|null
$destination  : string
$icon  : string|null
$label  : string
$name  : string
$params  : array<string, string>
$post  : bool
$signal  : string|null
$target  : string|null
$type  : string
$variant  : string
$visibleInPickerMode  : bool
$visibleWhen  : callable(object): bool|null

Methods

__construct()  : mixed
create()  : static
getConfirm()  : string|null
getConfirmTitle()  : string|null
getConfirmYes()  : string|null
getDestination()  : string
getIcon()  : string|null
getLabel()  : string
getName()  : string
getParams()  : array<string, string>
getSignal()  : string|null
getTarget()  : string|null
getType()  : string
getVariant()  : string
isPost()  : bool
isVisibleFor()  : bool
Whether the action is rendered for this row; always `true` without a condition.
isVisibleInPickerMode()  : bool
setConfirm()  : static
Text of the confirmation dialog (JS confirm); null means no confirmation.
setConfirmTexts()  : static
Custom title and "yes" button of the confirmation modal: the default grid texts are for deleting, so for another action the button would lie. `null` means the default grid text.
setIcon()  : static
Key of the icon in the actions template (edit, cross, eye, …), see _actions.latte.
setLabel()  : static
setLink()  : static
Link to a presenter action.
setPost()  : static
The action is sent as POST (button instead of link), for writing signals with `#[Requires(methods: 'POST')]`: a GET link could be triggered by a robot or prefetch.
setSignal()  : static
Grid signal `handle<Signal>(int $id)`, e.g. `delete`. Sent by POST by default.
setTarget()  : static
setVariant()  : static
Button color role (`success`, `danger`, `secondary`, …) → `.btn--<variant>`.
setVisibleWhen()  : static
Per-row visibility condition: `fn(object $entity): bool`. Without it the action is always visible.
showInPickerMode()  : static

Constants

TYPE_SIGNAL

public mixed TYPE_SIGNAL = 'signal'

Properties

$confirm

protected string|null $confirm = null

$confirmTitle

protected string|null $confirmTitle = null

$confirmYes

protected string|null $confirmYes = null

$destination

protected string $destination = 'this'

$params

protected array<string, string> $params = []

URL parameter => property path

$signal

protected string|null $signal = null

$target

protected string|null $target = null

$type

protected string $type = self::TYPE_LINK

$variant

protected string $variant = 'secondary'

$visibleInPickerMode

protected bool $visibleInPickerMode = false

$visibleWhen

protected callable(object): bool|null $visibleWhen = null

per-row visibility condition, see setVisibleWhen()

Methods

__construct()

public final __construct(string $name) : mixed
Parameters
$name : string

create()

public static create(string $name) : static
Parameters
$name : string
Return values
static

getConfirm()

public getConfirm() : string|null
Return values
string|null

getConfirmTitle()

public getConfirmTitle() : string|null
Return values
string|null

getConfirmYes()

public getConfirmYes() : string|null
Return values
string|null

getDestination()

public getDestination() : string
Return values
string

getIcon()

public getIcon() : string|null
Return values
string|null

getLabel()

public getLabel() : string
Return values
string

getName()

public getName() : string
Return values
string

getParams()

public getParams() : array<string, string>
Return values
array<string, string>

getSignal()

public getSignal() : string|null
Return values
string|null

getTarget()

public getTarget() : string|null
Return values
string|null

getType()

public getType() : string
Return values
string

getVariant()

public getVariant() : string
Return values
string

isPost()

public isPost() : bool
Return values
bool

isVisibleFor()

Whether the action is rendered for this row; always `true` without a condition.

public isVisibleFor(object $entity) : bool
Parameters
$entity : object
Return values
bool

isVisibleInPickerMode()

public isVisibleInPickerMode() : bool
Return values
bool

setConfirm()

Text of the confirmation dialog (JS confirm); null means no confirmation.

public setConfirm(string|null $confirm) : static
Parameters
$confirm : string|null
Return values
static

setConfirmTexts()

Custom title and "yes" button of the confirmation modal: the default grid texts are for deleting, so for another action the button would lie. `null` means the default grid text.

public setConfirmTexts(string|null $title, string|null $yes) : static
Parameters
$title : string|null
$yes : string|null
Return values
static

setIcon()

Key of the icon in the actions template (edit, cross, eye, …), see _actions.latte.

public setIcon(string|null $icon) : static
Parameters
$icon : string|null
Return values
static

setLabel()

public setLabel(string $label) : static
Parameters
$label : string
Return values
static

Link to a presenter action.

public setLink(string $destination[, array<string, string> $params = [] ]) : static
Parameters
$destination : string
$params : array<string, string> = []

URL parameter => entity property path

Return values
static

setPost()

The action is sent as POST (button instead of link), for writing signals with `#[Requires(methods: 'POST')]`: a GET link could be triggered by a robot or prefetch.

public setPost([bool $post = true ]) : static
Parameters
$post : bool = true
Return values
static

setSignal()

Grid signal `handle<Signal>(int $id)`, e.g. `delete`. Sent by POST by default.

public setSignal(string $signal) : static
Parameters
$signal : string
Return values
static

setTarget()

public setTarget(string|null $target) : static
Parameters
$target : string|null
Return values
static

setVariant()

Button color role (`success`, `danger`, `secondary`, …) → `.btn--<variant>`.

public setVariant(string $variant) : static
Parameters
$variant : string
Return values
static

setVisibleWhen()

Per-row visibility condition: `fn(object $entity): bool`. Without it the action is always visible.

public setVisibleWhen(callable(object): bool $condition) : static

Needed when the decision depends on the row entity, e.g. deleting a job must disappear for closed rows. setAddLink()/addRowAction() are configured for the whole grid, so "not adding the action at all" does not work where open and closed rows sit side by side.

IMPORTANT: this mirrors the server guard, it does not replace it. The delete! signal calls the manager, which verifies the state itself (WorkListManager::beforeDelete()); hiding the button alone is no protection.

Parameters
$condition : callable(object): bool
Return values
static

showInPickerMode()

public showInPickerMode() : static
Return values
static
On this page

Search results