Skip to content

Commit

Permalink
Merge pull request #7 from wedevelopnl/fix/widget-admin-checks
Browse files Browse the repository at this point in the history
Update WidgetAdmin.php
  • Loading branch information
Dennisprins93 authored Apr 24, 2024
2 parents 1b0640d + cb7326e commit b76f709
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Admin/WidgetAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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]);
Expand Down

0 comments on commit b76f709

Please sign in to comment.