public function actionNew($eid) { $eid = (int) $eid; $id = EnrolledForm::findOne($eid); if ($id !== null) { $model = new AssessmentForm(); $student_id = (int) $id->student_id; $grade_level_id = (int) $id->grade_level_id; $student = StudentForm::findOne($id->student_id); $tuition = Tuition::find()->where(['grade_level_id' => $grade_level_id])->orderBy(['id' => SORT_DESC])->all(); $model->enrolled_id = $eid; $tid = (int) $tuition[0]['id']; $model->tuition_id = $tid; $model->has_sibling_discount = (int) $model->has_sibling_discount; $model->has_book_discount = (int) $model->has_book_discount; $model->has_honor_discount = (int) $model->has_honor_discount; if (!empty($tuition)) { $array = $tuition; } else { throw new NotFoundHttpException('Oops, Something went wrong.'); } //$tuition_detail = Tuition::find()->where(['grade_level_id' => $grade_level_id])->orderBy(['id' => SORT_DESC])->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('new', ['model' => $model, 'student' => $student, 'tid' => $tid, 'array' => $array]); } } else { throw new NotFoundHttpException('The requested page does not exist.'); } }