diff --git a/common/models/Cities.php b/common/models/Cities.php new file mode 100644 index 0000000..613e8e9 --- /dev/null +++ b/common/models/Cities.php @@ -0,0 +1,48 @@ + 255], + ]; + } + + /** + * @inheritdoc + */ + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'name' => 'Name', + 'is_active' => 'Is Active', + 'parent' => 'Parent', + ]; + } +} diff --git a/frontend/assets/AppAsset.php b/frontend/assets/AppAsset.php index a488c50..6c5924b 100755 --- a/frontend/assets/AppAsset.php +++ b/frontend/assets/AppAsset.php @@ -38,7 +38,7 @@ class AppAsset extends AssetBundle ]; public $depends = [ 'yii\web\YiiAsset', - 'backend\assets\FileUploadAsset' + 'backend\assets\FileUploadAsset', ]; public $jsOptions = array( 'position' => \yii\web\View::POS_HEAD diff --git a/frontend/config/main.php b/frontend/config/main.php index 49634ae..bb12a84 100755 --- a/frontend/config/main.php +++ b/frontend/config/main.php @@ -47,7 +47,6 @@ return [ 'showScriptName' => false, 'rules' => [ 'landing/' => 'landing/view', - 'site/city/' => 'site/city', ] ], ], diff --git a/frontend/controllers/SiteController.php b/frontend/controllers/SiteController.php index 0429521..a8c69e1 100755 --- a/frontend/controllers/SiteController.php +++ b/frontend/controllers/SiteController.php @@ -1,6 +1,7 @@ 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 actionCity($q = null, $id = null) { + \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + $out = ['results' => ['id' => '', 'text' => '']]; + if (!is_null($q)) { + $query = new Query; + $query->select('id, name AS text') + ->from('cities') + ->where(['like', 'name', $q]) + ->limit(20); + $command = $query->createCommand(); + $data = $command->queryAll(); + $out['results'] = array_values($data); + } + elseif ($id > 0) { + $out['results'] = ['id' => $id, 'text' => Cities::find($id)->name]; + } + return $out; } diff --git a/frontend/models/SignupForm.php b/frontend/models/SignupForm.php index 774cd75..3b49ebe 100755 --- a/frontend/models/SignupForm.php +++ b/frontend/models/SignupForm.php @@ -17,6 +17,7 @@ class SignupForm extends Model public $lastname; public $verifyCode; public $location; + public $type; /** * @inheritdoc @@ -39,6 +40,8 @@ class SignupForm extends Model ['verifyCode', 'captcha'], + ['type', 'integer'], + ['password', 'required'], ['password', 'string', 'min' => 6], ]; diff --git a/frontend/views/site/registration.php b/frontend/views/site/registration.php index d189a14..885dc2a 100644 --- a/frontend/views/site/registration.php +++ b/frontend/views/site/registration.php @@ -5,7 +5,9 @@ */ use yii\captcha\Captcha; use yii\widgets\ActiveForm; - $this->registerJsFile('/js/selectize.js'); + use kartik\select2\Select2; + use yii\web\JsExpression; + ?>
@@ -48,18 +50,26 @@
Кто Вы
-
-
- - -
-
- - -
-
+ + field ($model, 'type',['options'=> ['class'=>'check-radio-wr']]) + ->label (false) + ->radioList ( + [1 => 'Частное лицо', 2 => 'Компания'], + [ + 'item' => function($index, $label, $name, $checked, $value) { + $return = '
'; + $return .= ''; + $return .= ''; + $return .= '
'; + return $return; + } + ] + ); + ?> + +
@@ -75,36 +85,36 @@
- - + field($model, 'firstname')->textInput(['class'=>'custom-input-2'])?>
- - -
-
-
- -
-
- - - + field($model, 'lastname')->textInput(['class'=>'custom-input-2'])?>
+ field($model, 'location')->widget(Select2::classname(), [ + 'options' => ['placeholder' => 'Search for a city ...'], + 'pluginOptions' => [ + 'allowClear' => true, + 'minimumInputLength' => 3, + 'ajax' => [ + 'url' => \yii\helpers\Url::to(['site/city']), + 'dataType' => 'json', + 'data' => new JsExpression('function(params) { return {q:params.term}; }') + ], + 'escapeMarkup' => new JsExpression('function (markup) { return markup; }'), + 'templateResult' => new JsExpression('function(city) { return city.text; }'), + 'templateSelection' => new JsExpression('function (city) { return city.text; }'), + ], + ]); + ?> + + + +
-- libgit2 0.21.4