public function actionIndex($id = null, $action = null) { $model = new Menus(); if ($model->load($_POST)) { $sess = array(); $sess['type'] = $_POST['Menus']['type']; $sess['langs'] = $_POST['Menus']['langs']; Yii::$app->session->set('sessMenus', $sess); } $sess = Yii::$app->session->get('sessMenus'); $model->type = $sess['type']; $model->langs = $sess['langs'] ? $sess['langs'] : 'thai'; $type = new TblMenutype(); if ($type->load(Yii::$app->request->post())) { $type->langs = $model->langs; $type->gid = Yii::$app->user->identity->gid; if (!$type->save()) { throw new \ErrorException($model->getErrors()); } } switch ($action) { case 'published': $this->published($id); break; case 'order': $this->order($id, $_REQUEST['ordering'], $_REQUEST['direction']); break; case 'typedelete': $this->typedelete($id); break; } return $this->render('index', ['model' => $model, 'type' => $type]); }