Merge pull request #372 from creative-commoners/pulls/3.6/manymanythrough-editablecolumns

FIX Allow editing extra fields from ManyManyThroughList.
This commit is contained in:
Loz Calver 2023-08-21 09:06:49 +01:00 committed by GitHub
commit e7d7178719
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,7 @@ use SilverStripe\ORM\DataList;
use SilverStripe\ORM\DataObject; use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\DataObjectInterface; use SilverStripe\ORM\DataObjectInterface;
use SilverStripe\ORM\ManyManyList; use SilverStripe\ORM\ManyManyList;
use SilverStripe\ORM\ManyManyThroughList;
/** /**
* Allows inline editing of grid field records without having to load a separate * Allows inline editing of grid field records without having to load a separate
@ -165,7 +166,7 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
} }
} }
if ($list instanceof ManyManyList) { if ($list instanceof ManyManyList || $list instanceof ManyManyThroughList) {
$extra = array_intersect_key($form->getData() ?? [], (array) $list->getExtraFields()); $extra = array_intersect_key($form->getData() ?? [], (array) $list->getExtraFields());
} }
@ -250,7 +251,7 @@ class GridFieldEditableColumns extends GridFieldDataColumns implements
} }
} }
if (!$field && $list instanceof ManyManyList) { if (!$field && ($list instanceof ManyManyList || $list instanceof ManyManyThroughList)) {
$extra = $list->getExtraFields(); $extra = $list->getExtraFields();
if ($extra && array_key_exists($col, $extra ?? [])) { if ($extra && array_key_exists($col, $extra ?? [])) {