public function actionGetCities()
 {
     $arrResult = [];
     $country_id = Yii::$app->request->post('country_id');
     $arrCities = GeoCity::find()->where(['country_id' => $country_id])->orderBy('name_ru ASC')->all();
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $html = $this->renderAjax('/ajax/_cities', ['arrCities' => $arrCities]);
     $arrResult['html'] = $html;
     return $arrResult;
 }
Example #2
0
 ?>
         <div class="col-sm-6">
             <div class="chose_area">
                 <h5 class="header_title">Обьязательные поля </h5>
                 <ul class="user_info">
                     <label>Индекс:</label>
                     <?php 
 echo $form->field($model_form, 'post_index')->textInput(['width' => '20px!important'])->label('');
 ?>
                     <label>Страна:</label>
                     <?php 
 echo $form->field($model_form, 'country_id')->dropDownList(ArrayHelper::map(GeoCountry::find()->where(['id' => ['20', '112', '113']])->all(), 'id', 'name_ru'), ['onchange' => 'getArrCities()', 'id' => 'country'])->label('');
 ?>
                     <label>Город:</label>
                     <?php 
 echo $form->field($model_form, 'city_id')->dropDownList(ArrayHelper::map(GeoCity::find()->where(['country_id' => 20])->all(), 'id', 'name_ru'), ['id' => 'city'])->label('');
 ?>
                     <label>Улица:</label>
                     <?php 
 echo $form->field($model_form, 'street')->textInput(['width' => '20px!important'])->label('');
 ?>
                     <label>Имя:</label>
                     <?php 
 echo $form->field($model_form, 'first_name')->label('');
 ?>
                     <label>Фамилия:</label>
                     <?php 
 echo $form->field($model_form, 'second_name')->label('');
 ?>
                     <label>Отчество:</label>
                     <?php