Skip to content

Commit

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

Please sign in to comment.