From 1f0a78e57b1710b90c0c1827381e13ebe8b33dd7 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 9 Jul 2020 09:33:21 +1200 Subject: [PATCH] FIX More context for GridFieldDataColumns callbacks This emulates the callback signature from GridFieldEditableColumns in the symbiote/silverstripe-gridfieldextensions module, which extends GridFieldDataColumns. In case canEdit() fails, this component passes control back to the parent (rendering a standard column content rather than a formfield). Which can become an issue if you've defined custom 'callback' handlers on setDisplayFields() - GridFieldDataColumns passes in only one arg (`$record`), while GridFieldEditableColumns passes in three (`$record`, `$col` and `$grid`). While you could argue that this is a bug in the other module, I think this additional context is beneficial for the main GridFieldDataColumns use case as well, and it just happens to fix that bug. --- src/Forms/GridField/GridFieldDataColumns.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Forms/GridField/GridFieldDataColumns.php b/src/Forms/GridField/GridFieldDataColumns.php index 0afa2e51a..afb7cf43c 100644 --- a/src/Forms/GridField/GridFieldDataColumns.php +++ b/src/Forms/GridField/GridFieldDataColumns.php @@ -159,7 +159,7 @@ class GridFieldDataColumns implements GridField_ColumnProvider // Allow callbacks if (is_array($columnInfo) && isset($columnInfo['callback'])) { $method = $columnInfo['callback']; - $value = $method($record); + $value = $method($record, $columnName, $gridField); // This supports simple FieldName syntax } else {