Yii2 Override generic create Action in Rest ActiveController

后端 未结 3 897
半阙折子戏
半阙折子戏 2020-12-10 02:30

I have a Rest API in Yii2, and Yii generates all actions

view / update / create / delete

I want to change the comportement of createMethode et garde the othe

3条回答
  •  一向
    一向 (楼主)
    2020-12-10 02:43

    You can do the following

    class CountryController extends ActiveController
    {
        public $modelClass = 'common\models\Country';
    
        public function actions()
        {
            $actions = parent::actions();
            unset($actions['create']);
            return $actions;
        }
    
        public function actionCreate(){
            // implement here your code
    
        }
    
    }
    

提交回复
热议问题