/** * Creates a new Subscribers model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Subscribers(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['index']); } else { return $this->render('create', ['model' => $model]); } }
public function actionSubscribe() { $model = new Subscribers(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post()) && $model->validate()) { if ($model->save()) { return 'Спасибо. На указанный email оформлена подписка на новости института.'; } else { return 'Возникла ошибка оформления подписки. Попробуйте позднее.'; } } else { $errors = $model->errors[email]; return $errors[0]; } }