I have 3 modules in my application. Is there anyway share models between modules. How to call models defined in another modules.Within same module I can do something like User::model() but what if this model is defined in another module. Any suggestion.
You can import model class from another module by setImport in init method of module default class. For example, you want to use model class of TestModule in AdminModule ( Controller class in AdminModule will call model class of TestModule). In /modules/admin/AdminModule.php class (extends from CWebModule) , find init method and setImport like following:
public function init()
{
// this method is called when the module is being created
// you may place code here to customize the module or the application
// import the module-level models and components
$this->setImport(array(
'admin.models.*',
'application.modules.test.models.*',
'admin.components.*',
));
}
By this way, you just have to import model class from specific module you want.