コード例 #1
0
 /**
  * Creates a new Todo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($fid)
 {
     $model = new Todo();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->todo_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #2
0
 /**
  * Creates a new Todo model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Todo();
     $model->deleted = FALSE;
     $model->creator_id = Yii::$app->user->id;
     $model->updater_id = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->todo_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
コード例 #3
0
 /**
  * Displays a single Functionality model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     if (Yii::$app->user->can('viewProject', ['project' => $model->project], false)) {
         $todo = new Todo();
         $todo->creator_id = Yii::$app->user->id;
         $todo->updater_id = Yii::$app->user->id;
         $todo->deleted = false;
         $todo->functionality_id = $id;
         if ($todo->load(Yii::$app->request->post()) && $todo->save(false)) {
             \Yii::$app->getSession()->setFlash('success', Yii::t('todo', 'Todo saved'));
             $todo = new Todo();
             $todo->creator_id = Yii::$app->user->id;
             $todo->updater_id = Yii::$app->user->id;
             $todo->deleted = false;
             $todo->functionality_id = $id;
         }
         $dataProvider = new ActiveDataProvider(['query' => Todo::find()->andWhere(['or', ['functionality_id' => $id]])]);
         return $this->render('view', ['model' => $model, 'dataProvider' => $dataProvider, 'todo' => $todo]);
     }
     throw new NotFoundHttpException('The requested page does not exist.');
 }