将参数传递给accessRules exressions下面的代码不起作用因为$ owner_id没有在评估表达式的类中定义.任何想法如何解决它?
public function accessRules(){
$owner_id = $this->loadModel()->owner_id;
return array(
...
array('allow',
'actions'=>array('update'),
'expression'=>'$user->id==$owner_id',
));
}
Run Code Online (Sandbox Code Playgroud)
很难说出你要做什么或问题是什么,但在构建数组时我会使用"{}"和双引号而不是单引号,以便正确解释变量:
public function accessRules(){
$owner_id = $this->loadModel()->owner_id;
return array(
...
array('allow',
'actions'=>array('update'),
'expression'=>"{$user->id}=={$owner_id}",
));
}
| 归档时间: |
|
| 查看次数: |
9242 次 |
| 最近记录: |