From 8d52321410cdfa8cb643dd094e0c50353a33ccb4 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Thu, 10 Oct 2024 15:16:16 -0400 Subject: [PATCH 1/3] document how to dynamically add a custom list column type --- backend/lists.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/backend/lists.md b/backend/lists.md index 868ef9a3..26cbc8f4 100644 --- a/backend/lists.md +++ b/backend/lists.md @@ -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 From abb387c46469d1cc0821efe26591b8a84188519a Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 10 Oct 2024 13:18:42 -0600 Subject: [PATCH 2/3] Update backend/lists.md --- backend/lists.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/lists.md b/backend/lists.md index 26cbc8f4..5379bd17 100644 --- a/backend/lists.md +++ b/backend/lists.md @@ -1081,7 +1081,8 @@ public function boot() }); } ``` -Note: the order of the arguments is different than when using `registerListColumnTypes()` + +> **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. From 915ab1da06898de019a0e30833904028f99074f3 Mon Sep 17 00:00:00 2001 From: Luke Towers Date: Thu, 10 Oct 2024 13:19:34 -0600 Subject: [PATCH 3/3] Update backend/lists.md --- backend/lists.md | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/lists.md b/backend/lists.md index 5379bd17..b1480284 100644 --- a/backend/lists.md +++ b/backend/lists.md @@ -1071,6 +1071,7 @@ 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() {