Exemplo n.º 1
0
 /**
  * Creates a new Scholars model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Scholars();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->scholar_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
    /**
     * Creates a new Scholars model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
    public function actionCreate()
    {
        $model = new Scholars();
		
        if ($model->load(Yii::$app->request->post())) {
			$test2 = ArrayHelper::map(Schools::find()->joinWith('scholars')->where(['School_id'=>$model->scholar_school_id])->all(),'School_id','school_area');
			$test = array_values($test2)[0];
			$model->scholar_school_area = $test;
			$model->save();
            return $this->redirect(['view', 'id' => $model->scholar_id]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }