/**
  * Creates a new CsObjectTypes model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new CsObjectTypes();
     $model_trans = new CsObjectTypesTranslation();
     if ($model->load(Yii::$app->request->post()) and $model_trans->load(Yii::$app->request->post())) {
         if ($model->save()) {
             $model_trans->object_type_id = $model->id;
             $model_trans->orig_name = $model->name;
             $model_trans->save();
             return $this->redirect(['view', 'id' => $model->id]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'model_trans' => $model_trans]);
     }
 }
Beispiel #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslation()
 {
     $object_translation = CsObjectTypesTranslation::find()->where('lang_code="SR" and object_type_id=' . $this->id)->one();
     if ($object_translation) {
         return $object_translation;
     }
     return false;
 }
Beispiel #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getObjectTypesTranslations()
 {
     return $this->hasMany(CsObjectTypesTranslation::className(), ['lang_code' => 'code']);
 }