Widget inside a module in Yii

I am trying to create a widget inside a module and then load this widget from an "external" module. In particular, I am using a user module written by someone else. I do not want to have a separate page for displaying the login form, so I tried to make CPortlet / widget (confusion) displaying the login form. Basically, I moved the code from LoginController to this widget. Then I try to display the widget on some random page

<?php $this->widget('user.components.LoginForm'); ?>

However, I get an error

CWebApplication does not have a method named "encrypting".

in the UserIdentity class on this line:

else if(Yii::app()->controller->module->encrypting($this->password)!==$user->password)

This happens because I'm basically trying to execute this code in the context of the application, not the module. Thus, the trick "Yii :: app () -> controller-> module does not work properly.

  • What am I doing wrong: -\
  • . - , (/) ?

.

+5
2

,

Yii::app()->getModule('user')->encrypting($this->password)

Yii::app()->controller->module->encrypting($this->password)

, "" , , . .

, , . UserModule.php

public static function id() {
    return 'user';
}

, ,

Yii::app()->getModule(UserModule::id())->encrypting($this->password)

, , :

'application.modules.user.models.*',
'application.modules.user.components.*',

UserModule.php:

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(
        'user.models.*',
        'user.components.*',
    ));
}

, , - , , . , LoginForm, NOT , :

$model = new UserLogin;

UserLogin , , , , :

$module = Yii::app()->getModule(UserModule::id());
$model = new UserLogin;

, , , . http://www.yiiframework.com/forum/index.php?/topic/6449-access-another-modules-model/ , =)

+9

() MyUserIdentiy, CUserIdentity. , , , , .

- User/Login, , Yii, MyUserIdentity.

+1

All Articles