how to remove permission error?


am getting this error

You are not allowed to perform this action.'

even if I already placed the particular action inside the behavior of the particular controller that owns

that action

    public function behaviors() {

        return [

            'access' => [

                'class' => AccessControl::className(),

                'only' => ['list'],

                'rules' => [


                        'allow' => true,

                        'actions' => ['list'],

                        'roles' => ['@'],






the scenario was like this, I am calling the controller/action from another controllers view form action

 <form action ="<?php echo Yii::$app->urlManager->createUrl('/mycontroller/list'); ?>" method="post" role="form">

what happen is that, whenever I click the submit button of that form,i get the permission error.

but when i forced the browser by pressing the enter button of the keyboard, it goes through…what’s the problem of calling another /controller/action within the view of another controller ?

I also tried to add the action inside the view’s controller, but still no dice

It’s probably because of the built-in CSRF protection of Yii.

Instead of writing <form> tag manually, try using Html::beginForm() which automatically creates a hidden input for CSRF protection.