public function actionConfig($id)
 {
     $model = DynamicBlockModel::loadBlockConfigModel($id);
     if ($model->load(Yii::$app->request->post())) {
         $model->saveConfig();
         return $this->redirect(['config', 'id' => $id]);
     }
     return $this->render($model->widgetId, ['model' => $model]);
 }
示例#2
0
 public function actionSend()
 {
     if (!Yii::$app->request->isAjax) {
         return '';
     }
     Yii::$app->response->format = Response::FORMAT_JSON;
     $post = Yii::$app->request->post();
     $model = DynamicBlockModel::loadBlockConfigModel($post['formid']);
     if ($model !== null) {
         $msgModel = $this->buildModel($model, $post);
         if ($msgModel->validate()) {
             Yii::$app->mailer->compose()->setTo($model->email)->setFrom('*****@*****.**')->setSubject($model->subject)->setTextBody($this->getMessageBody($model, $post))->send();
             return ['status' => 'ok'];
         }
         return ['errors' => $msgModel->errors];
     }
     return ['errors' => ['Ошибка при отправке формы']];
 }