Example #1
0
 /**
  * Updates an existing Donate model.
  * If update is successful, the browser will be redirected to the 'update' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id = null, $partner_id = null)
 {
     if ($id) {
         $model = $this->findModel($id);
     } else {
         $model = new Donate();
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', __('Your changes have been saved successfully.'));
         return $this->redirect(['index']);
     } else {
         if (!$id) {
             $model->timestamp = Yii::$app->formatter->asDate(time());
             if ($partner_id) {
                 $model->partner_id = $partner_id;
             }
         }
         return $this->renderAjax('update', ['model' => $model]);
     }
 }