diff --git a/src/controllers/TBackendModelController.php b/src/controllers/TBackendModelController.php index 5d6ed8b..fc2e9fa 100644 --- a/src/controllers/TBackendModelController.php +++ b/src/controllers/TBackendModelController.php @@ -13,6 +13,7 @@ use skeeks\cms\backend\widgets\ControllerActionsWidget; use skeeks\cms\helpers\RequestResponse; use skeeks\cms\IHasName; +use skeeks\cms\models\CmsUser; use yii\base\InvalidConfigException; use yii\base\Model; use yii\db\ActiveRecord; @@ -255,10 +256,20 @@ public function getModel() if ($pk) { $modelClass = $this->modelClassName; + /** + * @var $newModel CmsUser + */ + $newModel = new $modelClass(); - $this->_model = $modelClass::find() - ->where([$this->modelPkAttribute => $pk]) - ->limit(1)->one(); + $q = $modelClass::find() + ->andWhere([$this->modelPkAttribute => $pk]); + + if ($newModel->hasAttribute("cms_site_id")) { + $q->cmsSite(); + } + + $this->_model = $q->limit(1) + ->one(); } }