liysd
(Liysd)
1
How to pass arguments to accessRules experessions
The code below doesn’t work becouse $owner_id is not defined in class where expression is evaluated. Any ideas how to fix it?
public function accessRules(){
$owner_id = $this->loadModel()->owner_id;
return array(
...
array('allow',
'actions'=>array('update'),
'expression'=>'$user->id==$owner_id',
));
}
zaccaria
(Matteo Falsitta)
2
'expression'=>'$user->id=='.$owner+id,
or
'expression'=>"\$user->id=='$owner_id'",
you can use -
array('allow',
'actions'=>array('update'),
'users'=>array(Yii::app()->user->name),
'expression' => '(Yii::app()->user->id == ($_GET[\'id\']))',
),
jhmilan
(Jhmilan)
4
You mean (typo error I guess)
Thanks so much