public function actionInsertoutput($id) { $datawiki = Outputbaseline::findOne(['id_base_line' => $id]); $data = Baseline::findOne(['id' => $id]); $class_name = '\\kemdikbud\\to\\models\\' . ucfirst(str_replace(['_'], [''], $datawiki->nama_tabel)); $model = new $class_name(); $dataProvider = new ActiveDataProvider(['query' => $class_name::find(), 'pagination' => ['pageSize' => 10]]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['viewoutput', 'id' => $id, 'dataProvider' => $dataProvider, 'data' => $data]); } else { return $this->render('_insertoutput', ['datawiki' => $datawiki, 'model' => $model]); } }
/** * Finds the Baseline model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Baseline the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Baseline::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }