Skip to content

Commit 322f3bd

Browse files
committed
Document ListViewPrimaryButton
1 parent 29b9ee3 commit 322f3bd

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

docs/php/api/list_views.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,47 @@ class ExampleListPage extends AbstractListViewPage
382382
}
383383
```
384384

385+
## Primary Button
386+
387+
A primary button can be displayed in the list view header using the `ListViewPrimaryButton` class.
388+
It supports two modes: a link that navigates to a URL, or a button that triggers an action via a CSS class.
389+
390+
### Link Button
391+
392+
```php
393+
class ExampleListView extends AbstractListView
394+
{
395+
public function __construct()
396+
{
397+
$this->setPrimaryButton(
398+
ListViewPrimaryButton::forLink(
399+
'wcf.example.add',
400+
FontAwesomeIcon::fromValues('plus'),
401+
LinkHandler::getInstance()->getControllerLink(ExampleAddForm::class),
402+
)
403+
);
404+
}
405+
}
406+
```
407+
408+
### Action Button
409+
410+
```php
411+
class ExampleListView extends AbstractListView
412+
{
413+
public function __construct()
414+
{
415+
$this->setPrimaryButton(
416+
ListViewPrimaryButton::forButton(
417+
'wcf.example.add',
418+
FontAwesomeIcon::fromValues('plus'),
419+
'exampleAddButton',
420+
)
421+
);
422+
}
423+
}
424+
```
425+
385426
## Events
386427

387428
Existing list views can be modified using events.

0 commit comments

Comments
 (0)