/** * actionCreatecategory function. * * @access public * @return json array */ public function actionCreatecategory() { Yii::$app->response->getHeaders()->set('Vary', 'Accept'); Yii::$app->response->format = Response::FORMAT_JSON; $model = new BlogTerms(); if ($model->load(Yii::$app->request->post())) { $model->type = 'category'; if ($model->validate() && $model->save()) { return ['success' => true, 'model' => $model]; } } return ['error' => $model->errors]; }