Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document how to dynamically add a custom list column type #216

Merged
merged 3 commits into from
Oct 10, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions backend/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,20 @@ public function evalUppercaseListColumn($value, $column, $record)
}
```

It is also possible to extend the Lists widget class to add a new column type like this:
```php
LukeTowers marked this conversation as resolved.
Show resolved Hide resolved
public function boot()
{
Backend\Widgets\Lists::extend(function ($widget) {
$widget->addDynamicMethod('evalUppercaseTypeValue', function ($record, $column, $value) {
return strtoupper($value);
});
});
}
```

> **NOTE**: the order of the arguments is different than when using `registerListColumnTypes()`

Using the custom list column type is as simple as calling it by name using the `type` option.

```yaml
Expand Down
Loading