Commit 1044f75df28c434fa9fe00f83a047a5dc1b67004
1 parent
5869ded4
form on main submit
Showing
4 changed files
with
21 additions
and
6 deletions
Show diff stats
common/messages/ru/app.php
frontend/controllers/SiteController.php
| ... | ... | @@ -122,6 +122,9 @@ |
| 122 | 122 | ] |
| 123 | 123 | ); |
| 124 | 124 | if($mailer->send()){ |
| 125 | + | |
| 126 | + \Yii::$app->response->setStatusCode(200); | |
| 127 | + | |
| 125 | 128 | return [ |
| 126 | 129 | 'success' => true, |
| 127 | 130 | 'message' => 'Success message', |
| ... | ... | @@ -134,6 +137,9 @@ |
| 134 | 137 | ]; |
| 135 | 138 | } |
| 136 | 139 | else{ |
| 140 | + | |
| 141 | + \Yii::$app->response->setStatusCode(500); | |
| 142 | + | |
| 137 | 143 | return [ |
| 138 | 144 | 'success' => false, |
| 139 | 145 | 'error' => 'mail didn\'t send', |
| ... | ... | @@ -142,6 +148,9 @@ |
| 142 | 148 | |
| 143 | 149 | } |
| 144 | 150 | else { |
| 151 | + | |
| 152 | + \Yii::$app->response->setStatusCode(500); | |
| 153 | + | |
| 145 | 154 | return [ |
| 146 | 155 | 'success' => false, |
| 147 | 156 | 'error' => $model->errors, | ... | ... |
frontend/views/layouts/main.php
| ... | ... | @@ -407,7 +407,7 @@ _________________________________________________________ --> |
| 407 | 407 | |
| 408 | 408 | <p>Спасибо, ваша заявка принята. Мы свяжемся с вами в ближайшее время</p> |
| 409 | 409 | <p class="text-center"> |
| 410 | - <button type="button" class="btn btn-template-primary" data-dismiss="modal">Close</button> | |
| 410 | + <button type="button" class="btn btn-template-primary" data-dismiss="modal"><?=\Yii::t("app", "Close")?></button> | |
| 411 | 411 | </p> |
| 412 | 412 | </div> |
| 413 | 413 | </div> | ... | ... |
frontend/web/js/script.js
| ... | ... | @@ -22,9 +22,14 @@ $( |
| 22 | 22 | $('#success-modal') |
| 23 | 23 | .modal('show'); |
| 24 | 24 | }, |
| 25 | - error: function() { | |
| 26 | - $('#feedback-modal') | |
| 27 | - .modal('hide'); | |
| 25 | + error: function(XHRobj) { | |
| 26 | + var errorObj = XHRobj.responseJSON.error; | |
| 27 | + | |
| 28 | + for(var key in errorObj){ | |
| 29 | + if(errorObj[key]){ | |
| 30 | + form.find('.field-feedback-'+key).addClass('has-error'); | |
| 31 | + } | |
| 32 | + } | |
| 28 | 33 | } |
| 29 | 34 | } |
| 30 | 35 | ); | ... | ... |