Search code examples
phpyiiyii-components

How can I redirect to update page when I click the menu item


I'm new to Yii framework. I have a user table which has username and password. I'm using the update page of user to reset password. Now, when I login with username and password I get a menu item as "password-reset" . When I click on this I like to get the update page of user who has logged in. Below is the code in main.php:

array('label'=>'Password-Reset', 'url'=>array('user/update'),'visible'=>(!Yii::app()->user->isGuest && Yii::app()->user->name=="admin"))

But , when I click this I get error 404. When logged in as test I should get the update page of test when I click "Password-Reset" menu item. How can I do this.


Solution

  • Add the user id to the link:

    array('label'=>'Password-Reset', 
          'url'=>array('user/update/'.Yii::app()->user->id),
          'visible'=>(!Yii::app()->user->isGuest)
    )