public function actionCreate()
 {
     $model = new Subject();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Subjects model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Subject();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $this->setScreeningSession('subject_hash', $model->hash);
         return $this->redirect(['index']);
     } else {
         if (Yii::$app->request->post('first_name')) {
             $model->first_name = Yii::$app->request->post('first_name');
         }
         if (Yii::$app->request->post('last_name')) {
             $model->last_name = Yii::$app->request->post('last_name');
         }
         if (Yii::$app->request->post('dob')) {
             $model->dob = Yii::$app->request->post('dob');
         }
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 3
0
 /**
  * Creates a new Subject model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Subject();
     if ($model->load(Yii::$app->request->post())) {
         $selectSchool = ArrayHelper::map(Scholar::find()->where(['scholar_id' => $model->scholar_scholar_id])->all(), 'school_school_id', 'school_school_id');
         $schoolID = array_values($selectSchool)[0];
         $model->scholar_school_school_id = $schoolID;
         $model->save();
         return $this->redirect(['view', 'id' => $model->subject_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 4
0
 /**
  * Creates a new Subject model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $username = Yii::$app->user->identity->username;
     $users = User::find()->all();
     $scholars = Scholar::find()->all();
     $model = new Subject();
     foreach ($users as $user) {
         foreach ($scholars as $scholar) {
             if ($user->username == $username && $user->id == $scholar->scholar_user_id) {
                 $model->scholar_scholar_id = $scholar->scholar_id;
                 $model->scholar_school_school_id = $scholar->school_school_id;
                 if ($model->load(Yii::$app->request->post()) && $model->save()) {
                     return $this->redirect(['view', 'id' => $model->subject_id]);
                 } else {
                     return $this->render('create', ['model' => $model]);
                 }
             }
         }
     }
 }