Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. <?php //pjax::begin(['enablePushState' => false]); ?>
  2. <div id="contact-form">
  3.  
  4. <?php $form = ActiveForm::begin(['action'=>'/quick-contact/create','id'=>'quick-contact','method'=>'post']); ?>
  5.  
  6. <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
  7.  
  8. <?= $form->field($model, 'email')->textInput(['maxlength' => true]) ?>
  9.  
  10. <?= $form->field($model, 'message')->textarea(['rows' => 2]) ?>
  11.  
  12. <div class="form-group">
  13. <?= Html::submitButton(Yii::t('app', 'Save'), ['class' => 'btn btn-success']) ?>
  14. </div>
  15.  
  16. <?php ActiveForm::end(); ?>
  17. </div>
  18.  
  19.  
  20. <div id="quick-contact-form">
  21. <?php if (Yii::$app->session->hasFlash('success')): ?>
  22. <div class="alert alert-success alert-dismissable">
  23. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  24. <h4><i class="icon fa fa-check"></i>Saved!</h4>
  25. <?= Yii::$app->session->getFlash('success') ?>
  26. </div>
  27. <?php endif; ?>
  28.  
  29. // display error message
  30. <?php if (Yii::$app->session->hasFlash('error')): ?>
  31. <div class="alert alert-danger alert-dismissable">
  32. <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
  33. <h4><i class="icon fa fa-check"></i>Saved!</h4>
  34. <?= Yii::$app->session->getFlash('error') ?>
  35. </div>
  36. <?php endif; ?>
  37. </div></div>
  38. <?php // pjax::end(); ?>
  39.  
  40. public function actionCreate()
  41. {
  42. $model = new QuickContact();
  43. if (Yii::$app->request->isAjax) {
  44. Yii::$app->response->format = yiiwebResponse::FORMAT_JSON;
  45. var_dump($_POST);
  46. if ($model->load(Yii::$app->requset->post()) && $model->save()) {
  47.  
  48. Yii::$app->session->setFlash('success','Thanks We will get in touch with you');
  49.  
  50. // $st = Yii::$app->getTable;
  51. // $email_template = $st->email_template(1);
  52. Yii::$app->mailer->compose()
  53. ->setTo('info@mywebsolutions.co.in')
  54. ->setFrom(['info@mywebsolutions.co.in'])
  55. ->setSubject('QuickContact')
  56. ->setHtmlBody('Request from - '.$model->name.'<br>'.'Email - '.$model->email. '<br>'.'Message - '.$model->message)
  57. ->send();
  58.  
  59. /* Yii::$app->mailer->compose('template', ['id' => 1, 'email_template' => $email_template, 'sender_name'=>$model->name,'message'=>$model->address])
  60.  
  61. ->setTo($this->email)
  62. ->setFrom([$email => "vedic"])
  63. ->setSubject($this->subject)
  64. //->setHtmlBody('Hi '.$this->name.'<br>'.'Welcome to Nexgen'.'<br>'.'We confirm of having received your Enquiry/feedback as below'.'<br>'.$this->body )
  65. ->send();
  66. */
  67. }else{
  68. Yii::$app->session->setFlash('error','There was an error in submission.');
  69. }
  70. //return $this->render('/site/index');
  71.  
  72. }
  73.  
  74. // return $this->renderPartial('/site/index');
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement