Commit f0f915df9a171a77beb555d456c6e382e3e13397
1 parent
77092529
add Vitaliy's widgets
Showing
7 changed files
with
102 additions
and
70 deletions
Show diff stats
backend/web/js/option.js
... | ... | @@ -17,14 +17,7 @@ function checkboxerInit() { |
17 | 17 | $(value).trigger('change'); |
18 | 18 | }); |
19 | 19 | } |
20 | -function accountRedraw() { | |
21 | - var type = $('input[name="User[type]"]:checked').val(); | |
22 | - if(type == 2) { | |
23 | - $('#form_definition').addClass('form_for_company'); | |
24 | - } else { | |
25 | - $('#form_definition').removeClass('form_for_company'); | |
26 | - } | |
27 | -} | |
20 | + | |
28 | 21 | $(function() { |
29 | 22 | var counter = 0; |
30 | 23 | $(document).on('click', '.add_row', function() { | ... | ... |
frontend/config/main.php
frontend/controllers/SiteController.php
... | ... | @@ -12,6 +12,7 @@ use frontend\models\ContactForm; |
12 | 12 | use frontend\models\Options; |
13 | 13 | use frontend\models\OptionValues; |
14 | 14 | use yii\base\InvalidParamException; |
15 | +use yii\db\Query; | |
15 | 16 | use yii\web\BadRequestHttpException; |
16 | 17 | use yii\web\Controller; |
17 | 18 | use yii\filters\VerbFilter; |
... | ... | @@ -48,6 +49,23 @@ class SiteController extends Controller |
48 | 49 | |
49 | 50 | |
50 | 51 | |
52 | + public function actionCity($query){ | |
53 | + \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; | |
54 | + $out = ['results' => ['id' => '', 'text' => '']]; | |
55 | + if (!is_null($query)) { | |
56 | + $query = new Query(); | |
57 | + $query->select('id, name AS text') | |
58 | + ->from('city') | |
59 | + ->where(['like', 'name', $query]) | |
60 | + ->limit(20); | |
61 | + $command = $query->createCommand(); | |
62 | + $data = $command->queryAll(); | |
63 | + $out['results'] = array_values($data); | |
64 | + } | |
65 | + | |
66 | + return $out; | |
67 | + } | |
68 | + | |
51 | 69 | |
52 | 70 | public function actionFormsModal() |
53 | 71 | { | ... | ... |
frontend/models/SignupForm.php
... | ... | @@ -13,6 +13,10 @@ class SignupForm extends Model |
13 | 13 | public $username; |
14 | 14 | public $email; |
15 | 15 | public $password; |
16 | + public $firstname; | |
17 | + public $lastname; | |
18 | + public $verifyCode; | |
19 | + public $location; | |
16 | 20 | |
17 | 21 | /** |
18 | 22 | * @inheritdoc |
... | ... | @@ -25,12 +29,16 @@ class SignupForm extends Model |
25 | 29 | ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], |
26 | 30 | ['username', 'string', 'min' => 2, 'max' => 255], |
27 | 31 | |
32 | + ['location', 'string', 'min' => 2, 'max' => 255], | |
33 | + | |
28 | 34 | ['email', 'filter', 'filter' => 'trim'], |
29 | 35 | ['email', 'required'], |
30 | 36 | ['email', 'email'], |
31 | 37 | ['email', 'string', 'max' => 255], |
32 | 38 | ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'], |
33 | 39 | |
40 | + ['verifyCode', 'captcha'], | |
41 | + | |
34 | 42 | ['password', 'required'], |
35 | 43 | ['password', 'string', 'min' => 6], |
36 | 44 | ]; | ... | ... |
frontend/views/accounts/general.php
... | ... | @@ -70,29 +70,23 @@ |
70 | 70 | </div> |
71 | 71 | <div class="general-who style border-general"> |
72 | 72 | <div class="general-who-title gen-admin-title">Кто вы:</div> |
73 | + | |
73 | 74 | <?= $form->field ($user, 'type') |
74 | - ->label ('Кто вы') | |
75 | - ->radioList ([1 => 'Частное лицо', 2 => 'Компания']); | |
76 | - ?> | |
77 | - | |
78 | -<!-- --><?//= $form->field ($user, 'type') | |
79 | -// ->label (false) | |
80 | -// ->radioList ( | |
81 | -// [1 => 'Male', 0 => 'Female'], | |
82 | -// [ | |
83 | -// 'item' => function($index, $label, $name, $checked, $value) { | |
84 | -// | |
85 | -// $return = '<label class="modal-radio">'; | |
86 | -// $return .= '<input type="radio" name="' . $name . '" value="' . $value . '" tabindex="3">'; | |
87 | -// $return .= '<i></i>'; | |
88 | -// $return .= '<span>' . ucwords($label) . '</span>'; | |
89 | -// $return .= '</label>'; | |
90 | -// | |
91 | -// return $return; | |
92 | -// } | |
93 | -// ] | |
94 | -// ); | |
95 | -// ?> | |
75 | + ->label (false) | |
76 | + ->radioList ( | |
77 | + [1 => 'Частное лицо', 2 => 'Компания'], | |
78 | + [ | |
79 | + 'item' => function($index, $label, $name, $checked, $value) { | |
80 | + $return = '<label>'; | |
81 | + $return .= '<input type="radio" name="' . $name . '" value="' . $value . '" '.($checked ? "checked" :"").' >'; | |
82 | + $return .= '<span></span>' . ucwords($label); | |
83 | + $return .= '</label>'; | |
84 | + | |
85 | + return $return; | |
86 | + } | |
87 | + ] | |
88 | + ); | |
89 | + ?> | |
96 | 90 | |
97 | 91 | |
98 | 92 | </div> | ... | ... |
frontend/views/site/registration.php
... | ... | @@ -3,7 +3,9 @@ |
3 | 3 | * @var $user common\models\User |
4 | 4 | * @var $user_info common\models\UserInfo |
5 | 5 | */ |
6 | + use yii\captcha\Captcha; | |
6 | 7 | use yii\widgets\ActiveForm; |
8 | + $this->registerJsFile('/js/selectize.js'); | |
7 | 9 | ?> |
8 | 10 | <div class="section-box content"> |
9 | 11 | <div class="section-box registration"> |
... | ... | @@ -15,13 +17,7 @@ |
15 | 17 | |
16 | 18 | <div class="input-blocks-wrapper"> |
17 | 19 | <div class="input-blocks"> |
18 | - <?= $form->field($model, 'username')?> | |
19 | - | |
20 | - <div class="form-group field-accountsform-email require has-erro"> | |
21 | - <label for="input-txt-1">Логин</label> | |
22 | - <input class="custom-input-2" id="input-txt-1" type="text"> | |
23 | - <div class="help-block">Значение «E-mail (Логин)» не является правильным email адресом.</div> | |
24 | - </div> | |
20 | + <?= $form->field($model, 'username')->textInput(['class'=>'custom-input-2'])?> | |
25 | 21 | </div> |
26 | 22 | <div class="input-blocks-help-wr"> |
27 | 23 | <div class="input-blocks-help">Логин должен содержать не менее 3-х символов, начинаться с английской буквы и заканчиваться буквой или цифрой. Допускаются английские буквы, цифры и знаки 'тире', 'подчеркивание', 'точка'</div> |
... | ... | @@ -31,8 +27,7 @@ |
31 | 27 | <div class="input-blocks-wrapper"> |
32 | 28 | <div class="input-blocks"> |
33 | 29 | |
34 | - <label for="input-txt-2">Пароль</label> | |
35 | - <input class="custom-input-2" id="input-txt-2" type="text"> | |
30 | + <?= $form->field($model, 'password')->passwordInput(['class'=>'custom-input-2'])?> | |
36 | 31 | |
37 | 32 | </div> |
38 | 33 | <div class="input-blocks-help-wr"> |
... | ... | @@ -42,8 +37,7 @@ |
42 | 37 | |
43 | 38 | <div class="input-blocks-wrapper"> |
44 | 39 | <div class="input-blocks"> |
45 | - <label for="input-txt-3">E-mail</label> | |
46 | - <input class="custom-input-2" id="input-txt-3" type="text"> | |
40 | + <?= $form->field($model, 'email')->textInput(['class'=>'custom-input-2'])?> | |
47 | 41 | </div> |
48 | 42 | <div class="input-blocks-help-wr"> |
49 | 43 | <div class="input-blocks-help">На этот адрес электронной почты будет отправлено уведомление о регистрации.</div> |
... | ... | @@ -55,6 +49,7 @@ |
55 | 49 | <div class="who-you-are-form-wr style"> |
56 | 50 | <div class="who-you-are-form"> |
57 | 51 | <div class="check-radio-wr"> |
52 | + | |
58 | 53 | <div class="custom-form-buttons"> |
59 | 54 | <input class="custom-radio" id="custom-radio-1" name="group-1" checked="checked" type="radio"> |
60 | 55 | <label for="custom-radio-1"><span></span>Частное лицо copy</label> |
... | ... | @@ -108,15 +103,6 @@ |
108 | 103 | <option value="5">Черкасы</option> |
109 | 104 | </select> |
110 | 105 | </div> |
111 | - | |
112 | - <!--<div class="input-blocks">--> | |
113 | - <!--<select name="" id="" >--> | |
114 | - <!--<option selected disabled></option>--> | |
115 | - <!--<option value="">Киев</option>--> | |
116 | - <!--<option value="">Киев</option>--> | |
117 | - <!--<option value="">Киев</option>--> | |
118 | - <!--</select>--> | |
119 | - <!--</div>--> | |
120 | 106 | </div> |
121 | 107 | |
122 | 108 | <div class="input-blocks-wrapper city-two"> |
... | ... | @@ -126,18 +112,21 @@ |
126 | 112 | </div> |
127 | 113 | <div class="form-help-two">Если вашего города нет в списке, введите его. </div> |
128 | 114 | </div> |
129 | - | |
130 | - <div class="input-blocks-wrapper captcha"> | |
131 | - <div class="input-blocks-captcha"> | |
132 | - <img id="accountsform-verifycode-image" src="/images/captcha.png" alt=""> | |
133 | - </div> | |
134 | - </div> | |
135 | - | |
136 | 115 | <div class="input-blocks-wrapper"> |
137 | - <div class="input-blocks"> | |
138 | - <label for="input-txt-8">Введите проверочный код</label> | |
139 | - <input class="custom-input-2" id="input-txt-8" type="text"> | |
140 | - </div> | |
116 | + <?= $form->field($model, 'verifyCode')->widget(Captcha::className(), [ | |
117 | + 'template' => ' | |
118 | + <div class="input-blocks-wrapper"> | |
119 | + <div class="input-blocks"> | |
120 | + <label for="input-txt-8">Введите проверочный код</label> | |
121 | + {input} | |
122 | + </div> | |
123 | + </div> | |
124 | + <div class="input-blocks-wrapper captcha"> | |
125 | + <div class="input-blocks-captcha"> | |
126 | + {image} | |
127 | + </div> | |
128 | + </div>', | |
129 | + ])->label(false) ?> | |
141 | 130 | </div> |
142 | 131 | <div class="input-blocks-wrapper button"> |
143 | 132 | <button type="submit" value="Submit">Зарегистрироваться</button> | ... | ... |
frontend/web/js/selectize.js
... | ... | @@ -3046,15 +3046,44 @@ |
3046 | 3046 | |
3047 | 3047 | $(document).ready(function() { |
3048 | 3048 | var $select = $('.control-group select').selectize({ |
3049 | - create: true, | |
3050 | - sortField: { | |
3051 | - field: 'text', | |
3052 | - direction: 'asc' | |
3053 | - }, | |
3054 | - dropdownParent: null, | |
3055 | - onDropdownClose: function() { | |
3056 | - $("#btnClear").css({display:'block'}) | |
3057 | - } | |
3049 | + valueField: 'AuthorId', | |
3050 | + labelField: 'AuthorName', | |
3051 | + searchField: ['AuthorName'], | |
3052 | + maxOptions: 10, | |
3053 | + minimumInputLength: 2, | |
3054 | + //create: function (input, callback) { | |
3055 | + // $.ajax({ | |
3056 | + // url: '/site/city', | |
3057 | + // data: { 'AuthorName': input }, | |
3058 | + // type: 'POST', | |
3059 | + // dataType: 'json', | |
3060 | + // success: function (response) { | |
3061 | + // return callback(response); | |
3062 | + // } | |
3063 | + // }); | |
3064 | + //}, | |
3065 | + render: { | |
3066 | + option: function (item, escape) { | |
3067 | + return '<div>' + escape(item.AuthorName) + '</div>'; | |
3068 | + } | |
3069 | + }, | |
3070 | + load: function (query, callback) { | |
3071 | + if (!query.length) return callback(); | |
3072 | + $.ajax({ | |
3073 | + url: '/site/city/' + query, | |
3074 | + type: 'POST', | |
3075 | + dataType: 'json', | |
3076 | + data: { | |
3077 | + maxresults: 10 | |
3078 | + }, | |
3079 | + error: function () { | |
3080 | + callback(); | |
3081 | + }, | |
3082 | + success: function (res) { | |
3083 | + callback(res); | |
3084 | + } | |
3085 | + }); | |
3086 | + } | |
3058 | 3087 | |
3059 | 3088 | }); |
3060 | 3089 | ... | ... |