Commit ab86aa3202e1be45d8a3edd35e32d286e2d04d38

Authored by alex
1 parent 2d8dfc5f

Валидация формы

common/models/Feedback.php
... ... @@ -118,6 +118,9 @@ class Feedback extends ArtboxFeedback
118 118 {
119 119  
120 120 return array_merge(
  121 + #родительские правила перетирали мои изменения касательно правила required,
  122 + # поэтому я вынес все правила кроме required cюда для того ,чтобы не поломать логику в других местах
  123 +
121 124 #parent::rules(),
122 125 [
123 126 [
... ... @@ -155,7 +158,7 @@ class Feedback extends ArtboxFeedback
155 158 ],
156 159 'required',
157 160 'message'=>Yii::t('app','requiredField'),
158   - 'on' => self::SCENARIO_DEFAULT,
  161 + 'on' => [self::SCENARIO_DEFAULT],
159 162 ],
160 163 [
161 164 [
... ... @@ -193,7 +196,7 @@ class Feedback extends ArtboxFeedback
193 196 [
194 197 ['name'],
195 198 'match',
196   - 'pattern' => '/^[a-zA-Zа-яА-ЯёЁ\s\-]+$/u',
  199 + 'pattern' => '/^[a-zA-Zа-яієїґ\'А-ЯІЄЇҐёЁ\s\-]+$/u',
197 200 'message'=> \Yii::t('app', 'wrongName'),
198 201 'on'=>[self::SCENARIO_FEEDBACK,self::SCENARIO_DEFAULT]
199 202 ],
... ...
frontend/controllers/SiteController.php
... ... @@ -129,7 +129,7 @@
129 129 12,
130 130 42,
131 131 ];
132   -
  132 +
133 133 $objects = Objectkb::find()
134 134 ->with('lang.alias')
135 135 ->where(
... ... @@ -182,8 +182,12 @@
182 182  
183 183 public function actionFeedback()
184 184 {
  185 +
185 186 Yii::$app->response->format = Response::FORMAT_JSON;
186   -
  187 + $test=[2,4,5,2,5];
  188 + $test=json_decode($test);
  189 + die($test);
  190 +
187 191 /**
188 192 * @var Mailer $mailer
189 193 */
... ... @@ -191,11 +195,11 @@
191 195 $settings = Settings::getInstance();
192 196  
193 197 if (empty(Yii::$app->request->post())) {
  198 +
194 199 throw new BadRequestHttpException();
195 200 } else {
196 201  
197 202 $post = Yii::$app->request->post('Feedback');
198   -
199 203 switch ($post[ 'topic' ]) {
200 204 case Feedback::SCENARIO_FEEDBACK :
201 205 $model = new Feedback([ 'scenario' => Feedback::SCENARIO_FEEDBACK ]);
... ...
frontend/views/site/contact.php
1 1 <?php
2   -
  2 +
3 3 /**
4 4 * @var View $this
5 5 * @var Feedback $contact
6 6 */
7   -
  7 +
8 8 #use artbox\core\models\Feedback;
9 9 use common\models\Feedback;
10 10 use common\models\Settings;
... ... @@ -12,43 +12,43 @@
12 12 use yii\helpers\Html;
13 13 use yii\bootstrap\ActiveForm;
14 14 use yii\web\View;
15   -
  15 +
16 16 MapAsset::register($this);
17 17 $settings = Settings::getInstance();
18 18 $seo = \Yii::$app->get('seo');
19   -
  19 +
20 20 $this->params['h1'] = \Yii::t('app', 'menu-contacts');
21 21 $this->params[ 'breadcrumbs' ][] = $this->params['h1'];
22   -
  22 +
23 23 $js = <<< JS
24 24 window.lat = {$settings->lat};
25 25 window.lon = {$settings->lon};
26 26 JS;
27   -
  27 +
28 28 $this->registerJs($js, View::POS_END);
29 29 ?>
30 30  
31 31 <div id="content">
32 32 <div class="container" id="contact">
33   -
  33 +
34 34 <section>
35   -
  35 +
36 36 <div class="row">
37 37 <div class="col-md-12">
38 38 <section>
39 39 <div class="heading">
40 40 <h2><?= \Yii::t('app', 'contact_title') ?></h2>
41 41 </div>
42   -
  42 +
43 43 <!-- <p class="lead">--><?//= \Yii::t('app', 'contact_text1') ?><!--</p>-->
44 44 <!-- <div class="contacts_photo"><img src="/img/contacts_photo.jpg" alt=""></div>-->
45 45 </section>
46 46 </div>
47 47 </div>
48   -
  48 +
49 49 </section>
50 50 <section>
51   -
  51 +
52 52 <div class="row">
53 53 <div class="col-md-4">
54 54 <div class="box-simple">
... ... @@ -76,8 +76,8 @@ JS;
76 76 </div>
77 77 <!-- /.box - simple-->
78 78 </div>
79   -
80   -
  79 +
  80 +
81 81 <div class="col-md-4">
82 82 <?php
83 83 if (!empty( $settings->phone )) {
... ... @@ -104,12 +104,12 @@ JS;
104 104 }
105 105 ?>
106 106 </div>
107   -
  107 +
108 108 <?php
109 109 if (!empty( $settings->email )) {
110 110 ?>
111 111 <div class="col-md-4">
112   -
  112 +
113 113 <div class="box-simple">
114 114 <div class="icon">
115 115 <i class="fa fa-envelope"></i>
... ... @@ -132,13 +132,13 @@ JS;
132 132 }
133 133 ?>
134 134 </div>
135   -
  135 +
136 136 </section>
137   -
  137 +
138 138 <section>
139   -
  139 +
140 140 <div class="row text-center">
141   -
  141 +
142 142 <div class="col-md-12">
143 143 <div class="heading">
144 144 <h2> <?= \Yii::t('app', 'ContactUs') ?> </h2>
... ... @@ -161,7 +161,7 @@ JS;
161 161 <?= $form->field($contact, 'name')
162 162 ->textInput()->label(\Yii::t('app', 'formname')); ?>
163 163 </div>
164   -
  164 +
165 165 <div class="col-sm-6">
166 166 <?= $form->field($contact, 'email')
167 167 ->textInput()->label('Email'); ?>
... ... @@ -178,7 +178,7 @@ JS;
178 178 ]
179 179 )->label(\Yii::t('app', 'formmess')); ?>
180 180 </div>
181   -
  181 +
182 182 <div class="col-sm-12 text-center">
183 183 <?= Html::submitButton(
184 184 '<i class="fa fa-envelope-o"></i> '.\Yii::t('app', 'LeaveMessage'),
... ... @@ -186,7 +186,7 @@ JS;
186 186 'class' => 'btn btn-template-main',
187 187 ]
188 188 ) ?>
189   -
  189 +
190 190 </div>
191 191 </div>
192 192 <!-- /.row -->
... ... @@ -194,10 +194,10 @@ JS;
194 194 </div>
195 195 </div>
196 196 <!-- /.row -->
197   -
  197 +
198 198 </section>
199   -
200   -
  199 +
  200 +
201 201 </div>
202 202 <!-- /#contact.container -->
203 203 </div>
... ...
frontend/views/site/individual.php
... ... @@ -9,7 +9,7 @@
9 9 */
10 10  
11 11 use artbox\core\components\SeoComponent;
12   - use artbox\core\models\Feedback;
  12 + use common\models\Feedback;
13 13 use common\models\Settings;
14 14 use yii\helpers\Html;
15 15 use yii\helpers\Url;
... ... @@ -61,7 +61,8 @@
61 61 </div>
62 62 </div>
63 63 <div class="row">
64   - <div style="text-align: center;margin-bottom: 35px;"><a href="#" class="btn button1 icon_phone modaled init-button-consultation press-consultation" data-title="<?= Yii::t('app', 'modal1') ?>" data-toggle="modal" data-target="#feedback-modal" style="margin: 0 auto;"><?= Yii::t('app', 'modal1_1') ?> <span><?= Yii::t('app', 'modal1_2') ?></span></a></div>
  64 + <div style="text-align: center;margin-bottom: 35px;"><a href="#" class="btn button1 icon_phone modaled init-button-consultation press-consultation"
  65 + data-title="<?= Yii::t('app', 'modal1') ?>" data-toggle="modal" data-target="#feedback-modal" style="margin: 0 auto;"><?= Yii::t('app', 'modal1_1') ?> <span><?= Yii::t('app', 'modal1_2') ?></span></a></div>
65 66 </div>
66 67 </div>
67 68 </section>
... ... @@ -167,7 +168,11 @@
167 168 </div>
168 169 </div>
169 170 <div class="col-md-12 col-xs-12 get_station_center">
170   - <a href="#" class="btn button1 icon_phone modaled init-button-consultation press-consultation" data-title="<?= Yii::t('app', 'modal1') ?>" data-toggle="modal" data-target="#feedback-modal"><?= Yii::t('app', 'modal1_1') ?> <span><?= Yii::t('app', 'modal1_2') ?></span></a>
  171 + <a href="#"
  172 + class="btn button1 icon_phone modaled init-button-consultation press-consultation"
  173 + data-title="<?= Yii::t('app', 'modal1') ?>" data-toggle="modal"
  174 + data-target="#feedback-modal"><?= Yii::t('app', 'modal1_1') ?>
  175 + <span><?= Yii::t('app', 'modal1_2') ?></span></a>
171 176 </div>
172 177 </div>
173 178 </div>
... ...
frontend/views/site/legal.php
... ... @@ -416,7 +416,12 @@ $this-&gt;registerJs($js, View::POS_END);
416 416 <p class="text-center"><?= Yii::t('app', 'sect3_21') ?></p>
417 417 </div>
418 418 <div class="col-md-12 col-xs-12" style="text-align:center;">
419   - <a href="#" class="btn button1 icon_stat modaled init-button-order press-order" data-title="<?= Yii::t('app', 'modal2') ?>" data-toggle="modal" data-target="#feedback-modal"><?= Yii::t('app', 'modal1_1') ?> <span><?= Yii::t('app', 'modal2_2') ?></span></a>
  419 + <a href="#"
  420 + class="btn button1 icon_stat modaled init-button-order press-order"
  421 + data-title="<?= Yii::t('app', 'modal2') ?>"
  422 + data-toggle="modal"
  423 + data-target="#feedback-modal">
  424 + <?= Yii::t('app', 'modal1_1') ?> <span><?= Yii::t('app', 'modal2_2') ?></span></a>
420 425 </div>
421 426 </div>
422 427 </div>
... ...