我在behavior()方法中设置了一些属性,但出现此错误
public function behaviors()
{
return [
'access'=>[
'class'=> AccessControl::className(),
'only'=>['create','update'],
'rules'=>[
'allow'=>true,
'roles'=>['@'],
],
],
'verbs' => [
'class' => VerbFilter::className(),
'actions' => [
'delete' => ['POST'],
],
],
];
}
请有人看到它来解决
答案 0 :(得分:0)
AccessControl::$rules
应该是规则数组,因此您需要类似以下内容:
'access' => [
'class' => AccessControl::className(),
'only' => ['create','update'],
'rules' => [
[
'allow' => true,
'roles' => ['@'],
],
],
],
答案 1 :(得分:-1)
只需按照以下代码进行更改
'access'=>[
'class'=> AccessControl::className(),
'rules'=>[
'actions'=>['create','update'],
'allow'=>true,
'roles'=>['@'],
],