/** * Model ID validation. * * @param string $attribute Attribute name * @param array $params Attribute params * * @return mixed */ public function validateModelId($attribute, $params) { /** @var ActiveRecord $class */ $class = Model::findIdentity($this->model_class); if ($class === null) { $this->addError($attribute, Module::t('comments', 'ERROR_MSG_INVALID_MODEL_ID')); } else { $model = $class->name; if ($model::find()->where(['id' => $this->model_id]) === false) { $this->addError($attribute, Module::t('comments', 'ERROR_MSG_INVALID_MODEL_ID')); } } }