コード例 #1
0
 /**
  * Creates a new ValidationMain model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new ValidationMain();
     if ($model->load(Yii::$app->request->post())) {
         if ($model->npp == "") {
             $max = ValidationMain::find()->select('npp')->max('npp');
             $model->npp = $max + 1;
         }
     }
     if (Yii::$app->request->post() && $model->save()) {
         return $this->redirect(['index', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }