Пример #1
0
 /**
  * (string|\yii\web\Response) actionCreate : Creates a new Personal model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param $unit
  * @return string|\yii\web\Response
  */
 public function actionCreate($unit = '%')
 {
     $model = new Personal();
     //var_dump(Yii::$app->request->post());
     //return;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         /** init personal attributes */
         $model->s_date = date('Ymd');
         $model->code1 = $model::getMaxCode();
         $model->selfno = 0;
         $model->childnum = 0;
         $model->checktime = 0;
         $model->e_date = '29990101';
         $model->unit = $unit;
         $model->personal_id = Personal::generatePersonal_id($unit);
         return $this->render('create', ['model' => $model, 'unitname' => Unit::getUnitnameByUnitcode($unit)]);
     }
 }