/** * Creates a new Incentive model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Incentive(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->incentive_id]); } else { return $this->render('create', ['model' => $model]); } }
/** * Creates a new Incentive model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Incentive(); 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; $selectArea = ArrayHelper::map(Scholar::find()->where(['scholar_id' => $model->scholar_scholar_id])->all(), 'allowance_allowance_area', 'allowance_allowance_area'); $area = array_values($selectArea)[0]; $model->scholar_allowance_allowance_area = $area; $model->save(); return $this->redirect(['view', 'id' => $model->incentive_id]); } else { return $this->render('create', ['model' => $model]); } }