Commit df90a7cb52d3c65f3a0cb42a797435fbc084d01f
1 parent
be2b3be7
правки по формам
Showing
3 changed files
with
55 additions
and
20 deletions
Show diff stats
frontend/config/main.php
| @@ -112,6 +112,10 @@ | @@ -112,6 +112,10 @@ | ||
| 112 | 'required', | 112 | 'required', |
| 113 | 113 | ||
| 114 | ], | 114 | ], |
| 115 | + [ | ||
| 116 | + ['name','phone'], | ||
| 117 | + 'string' | ||
| 118 | + ], | ||
| 115 | 119 | ||
| 116 | ], | 120 | ], |
| 117 | 'labels' => [ | 121 | 'labels' => [ |
| @@ -159,7 +163,19 @@ | @@ -159,7 +163,19 @@ | ||
| 159 | }); | 163 | }); |
| 160 | setTimeout(function () { | 164 | setTimeout(function () { |
| 161 | $("#overlay").fadeIn(400); | 165 | $("#overlay").fadeIn(400); |
| 162 | - $("#success_form").css("display", "block").animate({opacity: 1, top: pos}, 700); | 166 | + |
| 167 | + if(data.status=="success"){ | ||
| 168 | + $("#success_form").css("display", "block").animate({opacity: 1, top: pos}, 700); | ||
| 169 | + } | ||
| 170 | + else{ | ||
| 171 | + $("#success_form.error_form").css("display", "block").animate({opacity: 1, top: pos}, 700); | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + | ||
| 175 | + | ||
| 176 | + | ||
| 177 | + | ||
| 178 | + | ||
| 163 | },400)}', | 179 | },400)}', |
| 164 | 180 | ||
| 165 | ], | 181 | ], |
| @@ -180,13 +196,15 @@ | @@ -180,13 +196,15 @@ | ||
| 180 | ], | 196 | ], |
| 181 | [ | 197 | [ |
| 182 | [ | 198 | [ |
| 183 | - | ||
| 184 | 'name', | 199 | 'name', |
| 185 | 'phone', | 200 | 'phone', |
| 186 | ], | 201 | ], |
| 187 | 'required', | 202 | 'required', |
| 188 | 203 | ||
| 189 | - ] | 204 | + ], |
| 205 | + [['name','phone'], | ||
| 206 | + 'string' | ||
| 207 | + ], | ||
| 190 | ], | 208 | ], |
| 191 | 'labels' => [ | 209 | 'labels' => [ |
| 192 | 'message' => 'Message', | 210 | 'message' => 'Message', |
| @@ -209,7 +227,7 @@ | @@ -209,7 +227,7 @@ | ||
| 209 | 227 | ||
| 210 | ], | 228 | ], |
| 211 | 'buttonTemplate' => '<div class="button-wr">{button}</div>', | 229 | 'buttonTemplate' => '<div class="button-wr">{button}</div>', |
| 212 | - 'buttonContent' => '<i class="fa fa-envelope-o"></i>'.$send, | 230 | + 'buttonContent' => $send, |
| 213 | 'sendEmail' => true, | 231 | 'sendEmail' => true, |
| 214 | 'email' => 'alkhonko@gmail.com', | 232 | 'email' => 'alkhonko@gmail.com', |
| 215 | 'subject' => 'test tt22', | 233 | 'subject' => 'test tt22', |
| @@ -264,7 +282,11 @@ | @@ -264,7 +282,11 @@ | ||
| 264 | ], | 282 | ], |
| 265 | 'required', | 283 | 'required', |
| 266 | 284 | ||
| 267 | - ] | 285 | + ], |
| 286 | + [ | ||
| 287 | + ['name','phone'], | ||
| 288 | + 'string' | ||
| 289 | + ], | ||
| 268 | ], | 290 | ], |
| 269 | 'labels' => [ | 291 | 'labels' => [ |
| 270 | 'message' => 'Message', | 292 | 'message' => 'Message', |
| @@ -275,7 +297,9 @@ | @@ -275,7 +297,9 @@ | ||
| 275 | 'inputOptions' => [ | 297 | 'inputOptions' => [ |
| 276 | 'name' => [ | 298 | 'name' => [ |
| 277 | 'template' => '<div class="col-sm-12">{input}</div>', | 299 | 'template' => '<div class="col-sm-12">{input}</div>', |
| 278 | - 'labelOptions' => [ 'class' => 'callback_text_input_label' ] | 300 | + 'labelOptions' => [ 'class' => 'callback_text_input_label'], |
| 301 | + | ||
| 302 | + | ||
| 279 | ], | 303 | ], |
| 280 | 'message' => [ | 304 | 'message' => [ |
| 281 | 'type' => 'textarea', | 305 | 'type' => 'textarea', |
frontend/controllers/SiteController.php
| @@ -7,6 +7,7 @@ | @@ -7,6 +7,7 @@ | ||
| 7 | use common\models\slider\Slide; | 7 | use common\models\slider\Slide; |
| 8 | use Yii; | 8 | use Yii; |
| 9 | use yii\filters\VerbFilter; | 9 | use yii\filters\VerbFilter; |
| 10 | + use yii\helpers\Json; | ||
| 10 | use yii\swiftmailer\Mailer; | 11 | use yii\swiftmailer\Mailer; |
| 11 | use yii\web\BadRequestHttpException; | 12 | use yii\web\BadRequestHttpException; |
| 12 | use yii\web\Controller; | 13 | use yii\web\Controller; |
| @@ -43,7 +44,21 @@ | @@ -43,7 +44,21 @@ | ||
| 43 | ], | 44 | ], |
| 44 | ]; | 45 | ]; |
| 45 | } | 46 | } |
| 46 | - | 47 | + |
| 48 | + public function actionSave(){ | ||
| 49 | + | ||
| 50 | + $model=new Feedback(); | ||
| 51 | + $model->setScenario(Feedback::SCENARIO_CALLBACK); | ||
| 52 | + | ||
| 53 | + if(Yii::$app->request->post() && $model->load(Yii::$app->request->post())) | ||
| 54 | + { | ||
| 55 | + $model->save(); | ||
| 56 | + Yii::$app->response->format = Response::FORMAT_JSON; | ||
| 57 | + return Yii::$app->request->referrer; | ||
| 58 | + } | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + | ||
| 47 | /** | 62 | /** |
| 48 | * Displays homepage. | 63 | * Displays homepage. |
| 49 | * | 64 | * |
| @@ -53,6 +68,12 @@ | @@ -53,6 +68,12 @@ | ||
| 53 | { | 68 | { |
| 54 | $model=new Feedback(); | 69 | $model=new Feedback(); |
| 55 | $model->setScenario(Feedback::SCENARIO_CALLBACK); | 70 | $model->setScenario(Feedback::SCENARIO_CALLBACK); |
| 71 | + | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + | ||
| 75 | + | ||
| 76 | + | ||
| 56 | $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all(); | 77 | $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all(); |
| 57 | $articles = Article::find() | 78 | $articles = Article::find() |
| 58 | ->with('language') | 79 | ->with('language') |
frontend/views/site/index.php
| @@ -454,22 +454,12 @@ $moduleRequest=\Yii::$app->getModule('request_1'); | @@ -454,22 +454,12 @@ $moduleRequest=\Yii::$app->getModule('request_1'); | ||
| 454 | <div class="forms-wrapp"> | 454 | <div class="forms-wrapp"> |
| 455 | <div class="forms-title"><?=\Yii::t('app','Set your request');?></div> | 455 | <div class="forms-title"><?=\Yii::t('app','Set your request');?></div> |
| 456 | <?php $module2=\Yii::$app->getModule('request_2'); | 456 | <?php $module2=\Yii::$app->getModule('request_2'); |
| 457 | - #echo $module2->renderForm($this); | 457 | + echo $moduleRequest->renderForm($this); |
| 458 | ?> | 458 | ?> |
| 459 | 459 | ||
| 460 | - <?php $form=\yii\widgets\ActiveForm::begin();?> | ||
| 461 | - <?= $form->field($model,'name', | ||
| 462 | - [ 'template' => '{label}<div >{input}</div>{error}', | ||
| 463 | - 'labelOptions' => [ 'class' => 'callback_text_input_label' ]]); ?> | ||
| 464 | - <?= $form->field($model,'phone',[ 'template' => '{label}<div >{input}</div>{error}', | ||
| 465 | - 'labelOptions' => [ 'class' => 'callback_text_input_label' ]]); ?> | ||
| 466 | - <?= $form->field($model,'message',[ 'labelOptions' => [ 'class' => 'callback_text_input_label' ]])->textarea(); ?> | ||
| 467 | - <div class="button-wr"> | ||
| 468 | - <?= Html::submitButton($send);?> | ||
| 469 | - </div> | ||
| 470 | - <?php \yii\widgets\ActiveForm::end(); ?> | 460 | + |
| 471 | </div> | 461 | </div> |
| 472 | - <?php #echo $moduleRequest->renderForm($this); ?> | 462 | + |
| 473 | 463 | ||
| 474 | </div> | 464 | </div> |
| 475 | 465 |