예제 #1
0
 public function actionContact()
 {
     $customData = CustomData::find()->where(['key' => 'contact'])->one();
     $contact = json_decode($customData->value, TRUE);
     $model = new ConfigForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $data = json_encode(array('contact_data' => $model->contactData, 'contact_location' => $model->contactLocation));
         $customData->value = $data;
         $customData->update();
         return $this->refresh();
     } else {
         $model->contactData = $contact['contact_data'];
         $model->contactLocation = $contact['contact_location'];
         return $this->render('contact', ['model' => $model]);
     }
 }
예제 #2
0
 public function actionContact()
 {
     $this->layout = 'page';
     $model = new ContactForm();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $message = new Message();
         $message->fullname = $model->fullname;
         $message->subject = $model->subject;
         $message->email = $model->email;
         $message->message = $model->message;
         $message->date = time();
         $message->insert();
         Yii::$app->session->setFlash('contactFormSubmitted');
         return $this->refresh();
     } else {
         $customData = CustomData::find()->where(['key' => 'contact'])->one();
         $contactData = json_decode($customData->value, TRUE);
         return $this->render('contact', ['model' => $model, 'contactData' => $contactData]);
     }
 }