<?php
class usr1_UserController extends myCController
{
public function actionForgotPassword()
{
$branchesToUpdate = Adm3Branch::model()->findAll();
}
}
Here is the model:
<?php
class Adm3Branch extends myCActiveRecord
{
public $var_adm3_business_name;
public function defaultScope()
{
$guest = Yii::app()->user->isGuest;
$contrl = Yii::app()->controller->id; this returns "usr1_User"
$actn = Yii::app()->controller->action->id; this returns "forgotpassword"
...
But, If I use this controller:
<?php
class SiteController extends myCController
{
public function actionIndex()
{
$this->render('index');
}
public function actionLogin()
{
$loginModel = new UsrF1LoginForm;
$formToDisplay = 'Login';
$registerModel = new Usr1User;
$registerModel->scenario = 'insertUser';
$this->render('login_register', array(
'loginModel'=>$loginModel,
'registerModel'=>$registerModel,
'formToDisplay'=>$formToDisplay,
));
}
public function actionCreateEnterprise()
{
$branchesToUpdate = Adm3Branch::model()->findAll();
}
}
then it works fine and this function $actn = Yii::app()->controller->action->id, returns "createEnterprise" in the model.
All I can think to do is to change the statement in the model to:
Of course… but this is not the way you should write links… what would happen if you would change the URL rules… than all those "manual" links would be wrong.
Instead you should use createUrl() to generate links.
I always keep anything that will appear in a URL as lowercase, but that’s personal preference. It means that for controllers and actions that need to be shown as two words, you end up with class and action names like Member_areaController and actionChange_password(), which I find a little jarring, but I prefer that to having mixed case in the URL’s.