From 1bcc192399eca086f09666fafcb19b84bc612d5a Mon Sep 17 00:00:00 2001 From: Luca Haid Date: Mon, 10 Feb 2025 08:08:12 +0000 Subject: [PATCH] Update TTCrud.php --- lib/TTCrud/TTCrud.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/TTCrud/TTCrud.php b/lib/TTCrud/TTCrud.php index 7c963e1c3..daca7bbcc 100644 --- a/lib/TTCrud/TTCrud.php +++ b/lib/TTCrud/TTCrud.php @@ -84,21 +84,19 @@ class TTCrud extends mfBaseController { * @return array */ protected function getCrudConfig(): array { - if (method_exists($this, 'prepareCrudConfig')) { - $this->prepareCrudConfig(); - } + $column = array_search('createBy', array_column($this->columns, 'key')); - if ($column !== false && - isset($this->columns[$column]['modal']['items']) && - is_array($this->columns[$column]['modal']['items']) && - count($this->columns[$column]['modal']['items']) > 0 - ) { + if ($column !== false) { $this->columns[$column]['modal']['items'] = array_map(function ($user) { return ['value' => intval($user->id), 'text' => $user->name]; }, UserModel::search(['employee' => true])); } + if (method_exists($this, 'prepareCrudConfig')) { + $this->prepareCrudConfig(); + } + $columns = array_map(function ($column) { if (isset($column['type']) && (!isset($column['modal']) || !isset($column['modal']['type']))) {