public function run() { echo $this->form->field($this->model, $this->model->getCountryPropertyName())->dropDownList(ArrayHelper::map(Country::find()->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), ['id' => 'location_country_id', 'prompt' => Yii::t('common/geo/country', 'Select country')]); if ($this->localized === $this->model->getCountryPropertyName()) { return; } echo $this->form->field($this->model, $this->model->getRegionPropertyName())->widget(DepDrop::className(), ['options' => ['id' => 'location_region_id', 'placeholder' => Yii::t('common/geo/region', 'Select region')], 'data' => ArrayHelper::map(Region::find()->where(['country_id' => $this->model->country_id])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), 'pluginOptions' => ['url' => Url::to(['/geo/region/list']), 'depends' => ['location_country_id']]]); if ($this->localized === $this->model->getRegionPropertyName()) { return; } echo $this->form->field($this->model, $this->model->getCityPropertyName())->widget(DepDrop::className(), ['options' => ['id' => 'location_city_id', 'cityholder' => Yii::t('common/geo/city', 'Select city')], 'data' => ArrayHelper::map(City::find()->where(['region_id' => $this->model->region_id])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), 'pluginOptions' => ['url' => Url::to(['/geo/city/list']), 'depends' => ['location_region_id']]]); if ($this->localized === $this->model->getCityPropertyName()) { return; } echo $this->form->field($this->model, 'address')->textInput(); }
/** * Renders the city part. */ protected function city() { $this->parts['{city}'] = $this->form->field($this->model, $this->model->getCityPropertyName())->widget(DepDrop::className(), ['options' => ['id' => 'location_city_id', 'cityholder' => Yii::t('jlorente/location', 'Select city')], 'data' => ArrayHelper::map(City::find()->where(['region_id' => $this->model->region_id])->orderBy(['name' => SORT_ASC])->all(), 'id', 'name'), 'pluginOptions' => ['url' => Url::to(["/{$this->module->id}/city/list"]), 'depends' => ['location_region_id']]]); }