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.
This commit is contained in:
Ingo Schommer 2020-07-09 09:33:21 +12:00
parent d3d81ad96c
commit 1f0a78e57b
1 changed files with 1 additions and 1 deletions

View File

@ -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 {