Skip to content

Commit

Permalink
document how to dynamically add a custom list column type
Browse files Browse the repository at this point in the history
  • Loading branch information
mjauvin committed Oct 10, 2024
1 parent 8fb9bef commit 8d52321
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions backend/lists.md
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,19 @@ 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
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

0 comments on commit 8d52321

Please sign in to comment.