Final Class Yiisoft\Yii\DataView\GridView\Column\ActionButton
| Inheritance | Yiisoft\Yii\DataView\GridView\Column\ActionButton |
|---|
ActionButton represents a button in an action column of a grid.
// Simple button with static content and URL
$button = new ActionButton(
content: '✎',
url: '/edit',
title: 'Edit',
);
// Button with dynamic URL based on row data
$button = new ActionButton(
content: '❌',
url: static function (array|object $data, DataContext $context): string {
return '/delete/' . $data['id'];
},
title: 'Delete',
);
// Button with dynamic content and attributes
$button = new ActionButton(
content: static function (array|object $data, DataContext $context): string {
return $data['active'] ? 'Deactivate' : 'Activate';
},
url: '/toggle',
attributes: ['data-confirm' => 'Are you sure?'],
class: 'btn btn-sm',
);
// Button with dynamic CSS classes
$button = new ActionButton(
content: '🔎',
url: '/view',
title: 'View',
class: static function (array|object $data, DataContext $context): string {
return $data['active'] ? 'btn-success' : 'btn-secondary';
},
);
Public Properties
| Property | Type | Description | Defined By |
|---|---|---|---|
| $attributes | \Closure|array|null | Yiisoft\Yii\DataView\GridView\Column\ActionButton | |
| $class | \Closure|string|array|false|null | Yiisoft\Yii\DataView\GridView\Column\ActionButton | |
| $content | \Closure|string|\Stringable | Yiisoft\Yii\DataView\GridView\Column\ActionButton | |
| $overrideAttributes | boolean | Yiisoft\Yii\DataView\GridView\Column\ActionButton | |
| $title | ?string | Yiisoft\Yii\DataView\GridView\Column\ActionButton | |
| $url | \Closure|string|null | Yiisoft\Yii\DataView\GridView\Column\ActionButton |
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\Yii\DataView\GridView\Column\ActionButton |
Property Details
Method Details
| public mixed __construct ( Closure|string|\Stringable $content = '', Closure|string|null $url = null, array|Closure|null $attributes = null, array|Closure|false|string|null $class = false, string|null $title = null, boolean $overrideAttributes = false ) | ||
| $content | Closure|string|\Stringable |
Button content. To prevent HTML encoding use {@see \Yiisoft\Html\NoEncode::string()}.
If closure is used, its signature is: |
| $url | Closure|string|null |
Button URL. If closure is used, its signature is:
|
| $attributes | array|Closure|null |
HTML attributes. If closure is used, its signature is:
|
| $class | array|Closure|false|string|null |
CSS class(es). If closure is used, its signature is:
|
| $title | string|null |
Button title attribute. |
| $overrideAttributes | boolean |
Whether to override default attributes with custom ones instead of merging. |
public function __construct(
public readonly Closure|string|Stringable $content = '',
public readonly Closure|string|null $url = null,
public readonly Closure|array|null $attributes = null,
public readonly Closure|string|array|false|null $class = false,
public readonly ?string $title = null,
public readonly bool $overrideAttributes = false,
) {}
Signup or Login in order to comment.