public function actionSave($id = null, $languageId)
    {
        if (!empty($languageId)) {
            if (!empty($id)) {
                $model = $this->findModel($id);
            }
            else {
                $model = new OrderStatus();
            }

            $modelTranslation = $this->findOrCreateModelTranslation($model->id, $languageId);

            if ($modelTranslation->load(Yii::$app->request->post()) && $model->load(Yii::$app->request->post())) {
                $model->save();
                $modelTranslation->language_id = $languageId;
                $modelTranslation->order_status_id = $model->id;
                if ($modelTranslation->validate()) {
                    $modelTranslation->save();
                    \Yii::$app->session->setFlash('success', \Yii::t('cart', 'The record was successfully saved.'));
                } else {
                    \Yii::$app->session->setFlash('error', \Yii::t('cart', 'An error occurred when saving the record.'));
                }
                return $this->redirect(['save',
                    'id' => $model->id,
                    'languageId' => $languageId
                ]);
            }

            return $this->render('save',
                [
                    'model' => $model,
                    'modelTranslation' => $modelTranslation,
                    'languages' => Language::find()->all(),
                    'selectedLanguage' => Language::findOne($languageId)
                ]);
        } else throw new Exception(\Yii::t('cart', 'Language id can not be empty'));
    }
public function actionSave($id = null, $languageId)
    {
        if (!empty($languageId)) {
            if (!empty($id)) {
                $model = $this->findModel($id);
            }
            else {
                $model = new OrderStatus();
            }

            $modelTranslation = $this->findOrCreateModelTranslation($model->id, $languageId);

            if ($modelTranslation->load(Yii::$app->request->post()) && $model->load(Yii::$app->request->post())) {
                $model->save();
                $modelTranslation->language_id = $languageId;
                $modelTranslation->order_status_id = $model->id;
                if ($modelTranslation->validate()) {
                    $modelTranslation->save();
                    \Yii::$app->session->setFlash('success', \Yii::t('cart', 'The record was successfully saved.'));
                } else {
                    \Yii::$app->session->setFlash('error', \Yii::t('cart', 'An error occurred when saving the record.'));
                }
                return $this->redirect(['save',
                    'id' => $model->id,
                    'languageId' => $languageId
                ]);
            }

            return $this->render('save',
                [
                    'model' => $model,
                    'modelTranslation' => $modelTranslation,
                    'languages' => Language::find()->all(),
                    'selectedLanguage' => Language::findOne($languageId)
                ]);
        } else throw new Exception(\Yii::t('cart', 'Language id can not be empty'));
    }
public function actionSave ( $ id = null , $ languageId ) { if ( ! empty ( $ languageId ) ) { if ( ! empty ( $ id ) ) { $ model = $ this -> findModel ( $ id ) ; } else { $ model = new OrderStatus ( ) ; } $ modelTranslation = $ this -> findOrCreateModelTranslation ( $ model -> id , $ languageId ) ; if ( $ modelTranslation -> load ( Yii :: $ app -> request -> post ( ) ) && $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> save ( ) ; $ modelTranslation -> language_id = $ languageId ; $ modelTranslation -> order_status_id = $ model -> id ; if ( $ modelTranslation -> validate ( ) ) { $ modelTranslation -> save ( ) ; \ Yii :: $ app -> session -> setFlash ( 'success' , \ Yii :: t ( 'cart' , 'The record was successfully saved.' ) ) ; } else { \ Yii :: $ app -> session -> setFlash ( 'error' , \ Yii :: t ( 'cart' , 'An error occurred when saving the record.' ) ) ; } return $ this -> redirect ( [ 'save' , 'id' => $ model -> id , 'languageId' => $ languageId ] ) ; } return $ this -> render ( 'save' , [ 'model' => $ model , 'modelTranslation' => $ modelTranslation , 'languages' => Language :: find ( ) -> all ( ) , 'selectedLanguage' => Language :: findOne ( $ languageId ) ] ) ; } else throw new Exception ( \ Yii :: t ( 'cart' , 'Language id can not be empty' ) ) ; }
Creates a new or updates existing OrderStatus and OrderStatusTranslation models.
If creation is successful, the browser will be redirected to the 'view' page.
@param integer $id
@param integer $languageId
@return mixed
@throws Exception
Creates a new or updates existing OrderStatus and OrderStatusTranslation models . If creation is successful the browser will be redirected to the view page .