{"record":{"id":"71f61a78186be251","repo":"yiisoft/yii2","slug":"searchmodel-should-be-an-instance-of","errorCode":null,"errorMessage":"`{}`::$searchModel` should be an instance of `{}` or its DI compatible configuration.","messagePattern":"`(.+?)`::\\$searchModel` should be an instance of `(.+?)` or its DI compatible configuration\\.","errorType":"exception","errorClass":"InvalidConfigException","httpStatus":null,"severity":"error","filePath":"framework/data/DataFilter.php","lineNumber":292,"sourceCode":"\n    /**\n     * @param mixed $filter raw filter value.\n     */\n    public function setFilter($filter)\n    {\n        $this->_filter = $filter;\n    }\n\n    /**\n     * @return Model model instance.\n     * @throws InvalidConfigException on invalid configuration.\n     */\n    public function getSearchModel()\n    {\n        if (!is_object($this->_searchModel) || $this->_searchModel instanceof \\Closure) {\n            $model = Yii::createObject($this->_searchModel);\n            if (!$model instanceof Model) {\n                throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::className() . '` or its DI compatible configuration.');\n            }\n            $this->_searchModel = $model;\n        }\n        return $this->_searchModel;\n    }\n\n    /**\n     * @param Model|array|string|callable $model model instance or its DI compatible configuration.\n     * @throws InvalidConfigException on invalid configuration.\n     */\n    public function setSearchModel($model)\n    {\n        if (is_object($model) && !$model instanceof Model && !$model instanceof \\Closure) {\n            throw new InvalidConfigException('`' . get_class($this) . '::$searchModel` should be an instance of `' . Model::className() . '` or its DI compatible configuration.');\n        }\n        $this->_searchModel = $model;\n    }\n","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/yiisoft/yii2/blob/66f00d18a29b520f85e8e8f1e32d1e7e7b556cac/framework/data/DataFilter.php#L274-L310","documentation":"Error \"`{}`::$searchModel` should be an instance of `{}` or its DI compatible configuration.\" thrown in yiisoft/yii2.","triggerScenarios":"Thrown at framework/data/DataFilter.php:292 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"66f00d18a29b520f85e8e8f1e32d1e7e7b556cac","analyzedAt":"2026-08-17T05:17:23.470Z","schemaVersion":2},"datasetVersion":"2026-08-17T09:17:11.063Z"}