From b3689192151ec5d621317acaeff29fe5d41d51de Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Thu, 10 Oct 2024 15:20:15 -0400 Subject: [PATCH] Document how to dynamically add a custom list column type (#216) Documents https://github.com/wintercms/winter/commit/dda41ceaec709190d7fe587a5eb6bc81a403282a --- backend/lists.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/lists.md b/backend/lists.md index 868ef9a3..b1480284 100644 --- a/backend/lists.md +++ b/backend/lists.md @@ -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