示例#1
0
 /**
  * Creates a new Goal model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Goal();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect($model->url());
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionAddgoal($kpa_id)
 {
     $model = new Goal();
     $model->KPA_ID = $kpa_id;
     //$kpa = KPA::find()
     //  ->where(['id'=>$kpa_id]);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->User_ID = Yii::$app->user->identity->ID;
         if ($model->save()) {
             Yii::$app->session->setFlash('goalCreated', 'Goal has been saved');
         } else {
             Yii::$app->session->setFlash('goalCreated', 'There was a problem saving this goal');
         }
         return $this->render('addgoal', ['model' => $model, 'added' => true]);
     }
     return $this->render("addgoal", ['model' => $model, 'added' => false]);
 }