public function actionCreateAjax()
 {
     $model = new Callback();
     $module = Module::getInstance();
     $model->load(\Yii::$app->request->post());
     $model->createdAt = Date('Y-m-d H:i:s');
     if ($model->save()) {
         if ($module->email) {
             Yii::$app->mailer->compose($module->mailTemplate, ['model' => $model])->setFrom($module->email)->setTo($module->email)->setSubject($module->subject)->send();
         }
         return json_encode(true);
     }
     return json_encode($model->getErrors());
 }
예제 #2
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     $module = Module::getInstance();
     return ['id' => 'ID', 'name' => $module->nameTitle, 'phone' => $module->phoneTitle, 'message' => $module->messageTitle, 'time' => $module->timeTitle, 'createdAt' => 'Created At'];
 }