public function actionSubscribe()
 {
     $app = \Yii::$app;
     $model = new SubscribersRecord();
     if (\Yii::$app->request->isAjax && $model->load($_POST)) {
         \Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         \Yii::$app->session->setFlash('success', Language::t('flash', 'Вы успешно подписанны на обновления.'));
         return $this->redirect(Url::previous());
     }
 }
示例#2
0
 public function actionSubscribe()
 {
     $app = \Yii::$app;
     $model = new SubscribersRecord();
     if (\Yii::$app->request->isAjax && $model->load($_POST)) {
         \Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         \Yii::$app->session->setFlash('subscribeFormSubmitted');
         return $this->redirect(Url::previous());
     }
 }
示例#3
0
 /**
  * Finds the SubscribersRecord model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return SubscribersRecord the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = SubscribersRecord::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }