I have a weird scenario, I am getting the model name as a string, so If I wanted to use it, but how do I manage the import class part? Any ideas?
I have tried:
$model = new $tmpModel;
$className = "app\\models\\".$this->modelSave;
$model = Yii::createObject([
'class' => $className,
In YII way you can Use as ..
$className = 'path\folder\FileName'; $model = Yii::createObject([ 'class' => $className, ]);
This method can also identify dependent objects, instantiate them and inject them into the newly created object.