Commit be2b3be7fc9bbea9813e9a03d7fd3c7ff0174e49
1 parent
e095876b
правки по формам
Showing
7 changed files
with
166 additions
and
12 deletions
Show diff stats
common/models/Feedback.php
frontend/config/main.php
... | ... | @@ -89,17 +89,23 @@ |
89 | 89 | 'attributes' => [ |
90 | 90 | 'name', |
91 | 91 | 'phone', |
92 | + 'email', | |
92 | 93 | 'message', |
93 | 94 | |
95 | + | |
94 | 96 | ], |
95 | 97 | 'rules' => [ |
98 | + [ | |
99 | + ['email'], | |
100 | + 'email' | |
101 | + ], | |
96 | 102 | [ |
97 | 103 | [ 'message' ], |
98 | 104 | 'text', |
99 | 105 | ], |
100 | 106 | [ |
101 | 107 | [ |
102 | - | |
108 | + 'email', | |
103 | 109 | 'name', |
104 | 110 | 'phone', |
105 | 111 | ], |
... | ... | @@ -109,15 +115,21 @@ |
109 | 115 | |
110 | 116 | ], |
111 | 117 | 'labels' => [ |
112 | - 'message' => 'Message', | |
113 | - 'name' => 'Name', | |
114 | - 'phone' => 'Phone' | |
118 | + 'message' => 'Message', | |
119 | + 'name' => 'Name', | |
120 | + 'phone' => 'Phone', | |
121 | + 'email' => 'Email' | |
115 | 122 | ], |
116 | 123 | |
117 | 124 | 'inputOptions' => [ |
118 | 125 | 'name' => [ |
119 | 126 | 'template' => '<div class="col-sm-12">{input}</div>' |
120 | 127 | ], |
128 | + 'email' => [ | |
129 | + | |
130 | + 'template' =>'<div class="col-sm-12">{input}</div>', | |
131 | + | |
132 | + ], | |
121 | 133 | 'message' => [ |
122 | 134 | 'type' => 'textarea', |
123 | 135 | 'options' => [], |
... | ... | @@ -130,13 +142,13 @@ |
130 | 142 | ], |
131 | 143 | 'buttonTemplate' => '<div class="button-wr">{button}</div>', |
132 | 144 | |
133 | - 'buttonContent' => '<i class="fa fa-envelope-o"></i>'.$send, | |
145 | + 'buttonContent' => $send, | |
134 | 146 | 'sendEmail' => true, |
135 | 147 | 'email' => 'alkhonko@gmail.com', |
136 | 148 | 'subject' => 'test tt22', |
137 | 149 | 'ajax' => true, |
138 | 150 | 'formId' => 'contact-form', |
139 | - 'scenario' => 'callback', | |
151 | + 'scenario' => 'default', | |
140 | 152 | 'successCallback' => 'function (data) { |
141 | 153 | document.getElementById("contact-form").reset(); |
142 | 154 | |
... | ... | @@ -197,8 +209,88 @@ |
197 | 209 | |
198 | 210 | ], |
199 | 211 | 'buttonTemplate' => '<div class="button-wr">{button}</div>', |
212 | + 'buttonContent' => '<i class="fa fa-envelope-o"></i>'.$send, | |
213 | + 'sendEmail' => true, | |
214 | + 'email' => 'alkhonko@gmail.com', | |
215 | + 'subject' => 'test tt22', | |
216 | + 'ajax' => true, | |
217 | + 'formId' => 'contact-form', | |
218 | + 'scenario' => 'callback', | |
219 | + 'successCallback' => 'function (data) { | |
220 | + document.getElementById("contact-form").reset(); | |
221 | + | |
222 | + | |
223 | + var pos = ($(window).scrollTop()) + 30; | |
224 | + | |
225 | + $(".forms_").animate({opacity: 0, top: "0"}, 200,function(){ | |
226 | + $(this).css("display", "none"); | |
227 | + }); | |
228 | + setTimeout(function () { | |
229 | + $("#overlay").fadeIn(400); | |
230 | + | |
231 | + if(data.status=="success"){ | |
232 | + $("#success_form").css("display", "block").animate({opacity: 1, top: pos}, 700); | |
233 | + } | |
234 | + else{ | |
235 | + $("#success_form.error_form").css("display", "block").animate({opacity: 1, top: pos}, 700); | |
236 | + } | |
237 | + | |
238 | + | |
239 | + | |
240 | + | |
241 | + },400)}', | |
242 | + | |
243 | + ], | |
244 | + 'request_2' => [ | |
245 | + 'class' => 'artbox\core\forms\Module', | |
246 | + 'activeRecord' => "common\models\Feedback", | |
247 | + 'templateForm' => '<div class="row">{form}</div>', | |
248 | + 'attributes' => [ | |
249 | + 'name', | |
250 | + 'phone', | |
251 | + 'message', | |
252 | + | |
253 | + ], | |
254 | + 'rules' => [ | |
255 | + [ | |
256 | + [ 'message' ], | |
257 | + 'text', | |
258 | + ], | |
259 | + [ | |
260 | + [ | |
261 | + | |
262 | + 'name', | |
263 | + 'phone', | |
264 | + ], | |
265 | + 'required', | |
266 | + | |
267 | + ] | |
268 | + ], | |
269 | + 'labels' => [ | |
270 | + 'message' => 'Message', | |
271 | + 'name' => 'Name', | |
272 | + 'phone' => 'Phone' | |
273 | + ], | |
274 | + | |
275 | + 'inputOptions' => [ | |
276 | + 'name' => [ | |
277 | + 'template' => '<div class="col-sm-12">{input}</div>', | |
278 | + 'labelOptions' => [ 'class' => 'callback_text_input_label' ] | |
279 | + ], | |
280 | + 'message' => [ | |
281 | + 'type' => 'textarea', | |
282 | + 'options' => [], | |
283 | + 'template' => '<div class="input-wr">{input}</div>' | |
284 | + ], | |
285 | + 'phone' => [ | |
286 | + 'template' => '<div class="col-sm-12">{input}</div>', | |
287 | + 'labelOptions' => [ 'class' => 'callback_text_input_label' ] | |
288 | + ], | |
289 | + | |
290 | + ], | |
291 | + 'buttonTemplate' => '<div class="button-wr">{button}</div>', | |
200 | 292 | |
201 | - 'buttonContent' => '<i class="fa fa-envelope-o"></i>'.$request1, | |
293 | + 'buttonContent' => '<i class="fa fa-envelope-o"></i>'.$send, | |
202 | 294 | 'sendEmail' => true, |
203 | 295 | 'email' => 'alkhonko@gmail.com', |
204 | 296 | 'subject' => 'test tt22', | ... | ... |
frontend/controllers/SiteController.php
... | ... | @@ -52,6 +52,7 @@ |
52 | 52 | public function actionIndex() |
53 | 53 | { |
54 | 54 | $model=new Feedback(); |
55 | + $model->setScenario(Feedback::SCENARIO_CALLBACK); | |
55 | 56 | $slides = Slide::find()->with('language')->where(['status' => true])->orderBy('sort')->all(); |
56 | 57 | $articles = Article::find() |
57 | 58 | ->with('language') | ... | ... |
frontend/views/layouts/main.php
... | ... | @@ -40,6 +40,13 @@ $seo=\Yii::$app->get('seo'); |
40 | 40 | |
41 | 41 | |
42 | 42 | <?php $this->endBody() ?> |
43 | + <style> | |
44 | + .required label::before | |
45 | + { | |
46 | + content: ""; | |
47 | + } | |
48 | + | |
49 | + </style> | |
43 | 50 | </body> |
44 | 51 | </html> |
45 | 52 | <?php $this->endPage() ?> |
46 | 53 | \ No newline at end of file | ... | ... |
frontend/views/site/index.php
... | ... | @@ -13,7 +13,12 @@ use artbox\core\models\Language; |
13 | 13 | */ |
14 | 14 | |
15 | 15 | |
16 | +$send="Отправить"; | |
17 | +$request1='Ваша заявка'; | |
18 | +if(strpos($_SERVER['REQUEST_URI'],"/ua")!==false) { | |
19 | + $send = "Вiдправити"; | |
16 | 20 | |
21 | +} | |
17 | 22 | |
18 | 23 | |
19 | 24 | $settings = Settings::getInstance(); |
... | ... | @@ -352,7 +357,7 @@ $moduleRequest=\Yii::$app->getModule('request_1'); |
352 | 357 | <?=\Yii::t('app','Set your request');?> |
353 | 358 | </div> |
354 | 359 | |
355 | - <?php echo $moduleRequest->renderForm($this); ?> | |
360 | + <?php echo $module->renderForm($this); ?> | |
356 | 361 | </div> |
357 | 362 | </td> |
358 | 363 | <td> |
... | ... | @@ -441,15 +446,31 @@ $moduleRequest=\Yii::$app->getModule('request_1'); |
441 | 446 | |
442 | 447 | <div class="forms-wrapp"> |
443 | 448 | <div class="forms-title"><?=\Yii::t('app','Your request1');?></div> |
444 | - <?php echo $moduleRequest->renderForm($this); ?> | |
449 | + <?php echo $module->renderForm($this); ?> | |
445 | 450 | </div> |
446 | 451 | </div> |
447 | 452 | <div id="callback" class="forms_" style="display: none;"> |
448 | 453 | <span id="modal_close"></span> |
449 | 454 | <div class="forms-wrapp"> |
450 | 455 | <div class="forms-title"><?=\Yii::t('app','Set your request');?></div> |
451 | - <?php echo $module->renderForm($this); ?> | |
452 | - </div> | |
456 | + <?php $module2=\Yii::$app->getModule('request_2'); | |
457 | + #echo $module2->renderForm($this); | |
458 | + ?> | |
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(); ?> | |
471 | + </div> | |
472 | + <?php #echo $moduleRequest->renderForm($this); ?> | |
473 | + | |
453 | 474 | </div> |
454 | 475 | |
455 | 476 | <div id="success_form" style="display: none;"> | ... | ... |
frontend/web/css/change.css
... | ... | @@ -8,3 +8,28 @@ |
8 | 8 | color:#333; |
9 | 9 | text-decoration: none; |
10 | 10 | } |
11 | + | |
12 | + | |
13 | +.callback_text_input_label,label.control-label | |
14 | +{ | |
15 | + margin-top: 12px; | |
16 | + float: left; | |
17 | + font-size: 14px; | |
18 | + font-weight: 500; | |
19 | +} | |
20 | +input ,.form-control{ | |
21 | + width: 100%; | |
22 | + float: left; | |
23 | + outline: none !important; | |
24 | + height: 38px; | |
25 | + background: #f6f6f6; | |
26 | + border: 1px solid #f6f6f6; | |
27 | + padding-left: 8px; | |
28 | + margin-top: 5px; | |
29 | + resize: none; | |
30 | + box-shadow: none; | |
31 | + border-radius: 4px; | |
32 | +} | |
33 | +.form-wrapp{ | |
34 | + padding:0 15px; | |
35 | +} | ... | ... |
frontend/widgets/LanguageWidget.php
... | ... | @@ -141,6 +141,13 @@ |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | + foreach ($this->links as &$link){ | |
145 | + if($link['title']=='ru') { | |
146 | + $link['title']=($language::getCurrent()->url=='ru')?'рус':'рос'; | |
147 | + } | |
148 | + elseif($link['title']=='ua')$link['title']='укр'; | |
149 | + } | |
150 | + | |
144 | 151 | # определяем, какой же из шаблонов нам нужен |
145 | 152 | if(!isset($this->layoutCondition) |
146 | 153 | || !in_array($this->layoutCondition,[self::LAYOUT_DEFAULT,self::LAYOUT_LI,self::LAYOUT_UL]) | ... | ... |