diff --git a/backend/web/js/option.js b/backend/web/js/option.js index 298e76e..c62a57b 100755 --- a/backend/web/js/option.js +++ b/backend/web/js/option.js @@ -17,14 +17,7 @@ function checkboxerInit() { $(value).trigger('change'); }); } -function accountRedraw() { - var type = $('input[name="User[type]"]:checked').val(); - if(type == 2) { - $('#form_definition').addClass('form_for_company'); - } else { - $('#form_definition').removeClass('form_for_company'); - } -} + $(function() { var counter = 0; $(document).on('click', '.add_row', function() { diff --git a/frontend/config/main.php b/frontend/config/main.php index bb12a84..49634ae 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -47,6 +47,7 @@ return [ 'showScriptName' => false, 'rules' => [ 'landing/' => 'landing/view', + 'site/city/' => 'site/city', ] ], ], diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index d45ee4f..0429521 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -12,6 +12,7 @@ use frontend\models\ContactForm; use frontend\models\Options; use frontend\models\OptionValues; use yii\base\InvalidParamException; +use yii\db\Query; use yii\web\BadRequestHttpException; use yii\web\Controller; use yii\filters\VerbFilter; @@ -48,6 +49,23 @@ class SiteController extends Controller + public function actionCity($query){ + \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = ['results' => ['id' => '', 'text' => '']]; + if (!is_null($query)) { + $query = new Query(); + $query->select('id, name AS text') + ->from('city') + ->where(['like', 'name', $query]) + ->limit(20); + $command = $query->createCommand(); + $data = $command->queryAll(); + $out['results'] = array_values($data); + } + + return $out; + } + public function actionFormsModal() { diff --git a/frontend/models/SignupForm.php b/frontend/models/SignupForm.php index a894a5e..774cd75 100755 --- a/frontend/models/SignupForm.php +++ b/frontend/models/SignupForm.php @@ -13,6 +13,10 @@ class SignupForm extends Model public $username; public $email; public $password; + public $firstname; + public $lastname; + public $verifyCode; + public $location; /** * @inheritdoc @@ -25,12 +29,16 @@ class SignupForm extends Model ['username', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This username has already been taken.'], ['username', 'string', 'min' => 2, 'max' => 255], + ['location', 'string', 'min' => 2, 'max' => 255], + ['email', 'filter', 'filter' => 'trim'], ['email', 'required'], ['email', 'email'], ['email', 'string', 'max' => 255], ['email', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'], + ['verifyCode', 'captcha'], + ['password', 'required'], ['password', 'string', 'min' => 6], ]; diff --git a/frontend/views/accounts/general.php b/frontend/views/accounts/general.php index 37bdc00..1766248 100755 --- a/frontend/views/accounts/general.php +++ b/frontend/views/accounts/general.php @@ -70,29 +70,23 @@
Кто вы:
+ field ($user, 'type') - ->label ('Кто вы') - ->radioList ([1 => 'Частное лицо', 2 => 'Компания']); - ?> - -field ($user, 'type') -// ->label (false) -// ->radioList ( -// [1 => 'Male', 0 => 'Female'], -// [ -// 'item' => function($index, $label, $name, $checked, $value) { -// -// $return = ''; -// -// return $return; -// } -// ] -// ); -// ?> + ->label (false) + ->radioList ( + [1 => 'Частное лицо', 2 => 'Компания'], + [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = ''; + + return $return; + } + ] + ); + ?>
diff --git a/frontend/views/site/registration.php b/frontend/views/site/registration.php index daf311e..d189a14 100644 --- a/frontend/views/site/registration.php +++ b/frontend/views/site/registration.php @@ -3,7 +3,9 @@ * @var $user common\models\User * @var $user_info common\models\UserInfo */ + use yii\captcha\Captcha; use yii\widgets\ActiveForm; + $this->registerJsFile('/js/selectize.js'); ?>
@@ -15,13 +17,7 @@
- field($model, 'username')?> - - + field($model, 'username')->textInput(['class'=>'custom-input-2'])?>
Логин должен содержать не менее 3-х символов, начинаться с английской буквы и заканчиваться буквой или цифрой. Допускаются английские буквы, цифры и знаки 'тире', 'подчеркивание', 'точка'
@@ -31,8 +27,7 @@
- - + field($model, 'password')->passwordInput(['class'=>'custom-input-2'])?>
@@ -42,8 +37,7 @@
- - + field($model, 'email')->textInput(['class'=>'custom-input-2'])?>
На этот адрес электронной почты будет отправлено уведомление о регистрации.
@@ -55,6 +49,7 @@
+
@@ -108,15 +103,6 @@
- - - - - - - - -
@@ -126,18 +112,21 @@
Если вашего города нет в списке, введите его.
- -
-
- -
-
-
-
- - -
+ field($model, 'verifyCode')->widget(Captcha::className(), [ + 'template' => ' +
+
+ + {input} +
+
+
+
+ {image} +
+
', + ])->label(false) ?>
diff --git a/frontend/web/js/selectize.js b/frontend/web/js/selectize.js index 2c301f6..c635605 100644 --- a/frontend/web/js/selectize.js +++ b/frontend/web/js/selectize.js @@ -3046,15 +3046,44 @@ $(document).ready(function() { var $select = $('.control-group select').selectize({ - create: true, - sortField: { - field: 'text', - direction: 'asc' - }, - dropdownParent: null, - onDropdownClose: function() { - $("#btnClear").css({display:'block'}) - } + valueField: 'AuthorId', + labelField: 'AuthorName', + searchField: ['AuthorName'], + maxOptions: 10, + minimumInputLength: 2, + //create: function (input, callback) { + // $.ajax({ + // url: '/site/city', + // data: { 'AuthorName': input }, + // type: 'POST', + // dataType: 'json', + // success: function (response) { + // return callback(response); + // } + // }); + //}, + render: { + option: function (item, escape) { + return '
' + escape(item.AuthorName) + '
'; + } + }, + load: function (query, callback) { + if (!query.length) return callback(); + $.ajax({ + url: '/site/city/' + query, + type: 'POST', + dataType: 'json', + data: { + maxresults: 10 + }, + error: function () { + callback(); + }, + success: function (res) { + callback(res); + } + }); + } }); -- libgit2 0.21.4