/**
  * Creates a new ModelCategory model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ModelCategory();
     //set data from default model
     if (Yii::$app->request->get('source_id')) {
         $sourceModel = ModelCategory::findOne(['id' => Yii::$app->request->get('source_id')]);
         if (!empty($sourceModel)) {
             $model->attributes = $sourceModel->attributes;
             $model->domain_id = Yii::$app->user->identity->domain_id;
         }
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'categories' => ModelCategory::find()->noParents()->all()]);
     }
 }