/** * Creates a new StudentForm model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new StudentForm(); $gen_date = date('ymdHis'); $py = (int) substr($gen_date, 0, 2); $pm = (int) substr($gen_date, 2, 2); $pd = (int) substr($gen_date, 4, 2); $ph = (int) substr($gen_date, 6, 2); $pi = (int) substr($gen_date, 8, 2); $ps = (int) substr($gen_date, 10, 2); $parsed = $py . $pm . $pd . $ph . $pi . $ps; $model->id = $parsed; $model->status = 1; if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->session->setFlash('success', 'New student successfully created!'); return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('create', ['model' => $model]); } }