Commit ab86aa3202e1be45d8a3edd35e32d286e2d04d38

Authored by alex
1 parent 2d8dfc5f

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

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