Example #1
0
 /**
  * Updates an existing Customer model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     //$model = (new Customer(['scenario' => 'update']))->findOne($id);
     $model = $this->findModel($id);
     $model->setScenario('update');
     if (Yii::$app->request->post()) {
         //时间转化
         $post = General::dateTimeAsInt(Yii::$app->request->post(), 'Customer', ['birthday']);
         if ($model->load($post) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('update', ['model' => $model]);
 }