From cb7326ea5e21fc10735d008d5f64a711453c4acb Mon Sep 17 00:00:00 2001 From: Dennis Prins Date: Wed, 24 Apr 2024 10:28:25 +0200 Subject: [PATCH] Update WidgetAdmin.php --- src/Admin/WidgetAdmin.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Admin/WidgetAdmin.php b/src/Admin/WidgetAdmin.php index 7ada68d..931aaba 100644 --- a/src/Admin/WidgetAdmin.php +++ b/src/Admin/WidgetAdmin.php @@ -48,6 +48,11 @@ class WidgetAdmin extends ModelAdmin public function getGridField(): GridField { $gridField = parent::getGridField(); + + if (!in_array($gridField->getModelClass(), ClassInfo::subclassesFor(Widget::class), true)) { + return $gridField; + } + $dataList = $gridField->getList(); if ($dataList instanceof DataList) { @@ -72,6 +77,11 @@ public function getGridField(): GridField public function getEditForm($id = null, $fields = null): Form { $form = parent::getEditForm(); + + if (!in_array($this->getModelClass(), ClassInfo::subclassesFor(Widget::class), true)) { + return $form; + } + $formFields = $form->Fields(); $currentModelClass = $this->getModelClass(); $dataList = $currentModelClass::get()->filter(['IsPartOfCollection' => false]);