Example #1
0
 public function getNameByTemplate()
 {
     $thisPlaceArea = $this->getPlaceArea();
     switch ($thisPlaceArea->getType()) {
         case PlaceArea::TYPE_COUNTRY:
             return $this->country->getName();
         case PlaceArea::TYPE_REGION:
             return $this->region->getName() . '. ' . $this->country->getName();
         case PlaceArea::TYPE_TOWN:
             return $this->town->getName() . '. ' . $this->country->getName();
     }
 }
Example #2
0
 /**
  * REQUEST:
  * - term str
  * @return array
  */
 public function actionCountry()
 {
     $term = \Yii::$app->request->get('term');
     \Yii::$app->response->format = Response::FORMAT_JSON;
     return \cs\models\Place\Country::findAll($term);
 }
Example #3
0
 /**
  * Возращает список городов по запросу get param=term
  *
  * @return string JSON
  */
 public function actionPlace_country()
 {
     $term = \Yii::$app->request->get('term');
     return Json::encode(\cs\models\Place\Country::findAll($term));
 }
Example #4
0
 private function renderItem($id, $name, \yii\web\View $view, $source, $idInt, $key)
 {
     // добавляю опции input'а
     $optionsName = $key . 'InputOptions';
     $inputOptions = $this->{$optionsName};
     if (!is_null($inputOptions)) {
         if (ArrayHelper::keyExists('class', $inputOptions)) {
             $inputOptions['class'] .= ' form-control ui-autocomplete-input';
         } else {
             $inputOptions['class'] = 'form-control ui-autocomplete-input';
         }
     } else {
         $inputOptions = ['class' => 'form-control ui-autocomplete-input'];
     }
     $attrName = $this->attribute . '_' . $key;
     $value = null;
     if ($this->model->hasProperty($attrName)) {
         $value = $this->model->{$attrName};
         if (!is_null($value)) {
             switch ($key) {
                 case 'town':
                     $value = Town::find($value)->getName();
                     break;
                 case 'region':
                     $value = Region::find($value)->getName();
                     break;
                 case 'country':
                     $value = Country::find($value)->getName();
                     break;
             }
         }
     }
     return Html::input('text', $name, $value, ArrayHelper::merge($inputOptions, ['id' => $id, 'autocomplete' => 'off']));
 }