Models In Admin Module Conflicting With Models In Protected

I created same Models in admin MODULES where I used in protected/models. Here comes the conflict between those models in modules and protected.

How to recover from it otherthan changing names of models?

What is the conflict? Possibly you need to explicitly reference the admin.User model when you create an instance.

I usually place all models in protected/models and call from wherever. It saves doubling up model code. I do have an admin module and it works fine for both admin and main controllers.

The conflict is whenever I call function in protected/models, It calls function in model in admin module. The function what I call not present in that model (admin module). Therefore it shows error. Can you get my point?

I get your point!

Q: are you making this call from the admin module, or main app? As I have not used duel models, admin AND main. If from admin, my point is that Yii MAY be looking locally (admin) first, then main. As I commented earlier, you may have to reference the specific model you want (application.models.User) as apposed to just (User).

Disable importing all models from admin module. Change setting in AdminModule class:




class AdminModule extends CWebModule

{

   public function init()

   {

      parent::init();

      $this->setImport(array(

         // don't use this code:

         // 'admin.models.*',

         // instead that import individual(unique) models

         'admin.models.model1',

         'admin.models.model2',

         // and so on

         

         'admin.components.*',

      ));

   }

   //other stuff

}