コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Region::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'zone_id' => $this->zone_id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
コード例 #2
0
 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();
 }
コード例 #3
0
 /**
  * Renders the region part.
  */
 protected function region()
 {
     $this->parts['{region}'] = $this->form->field($this->model, $this->model->getRegionPropertyName())->widget(DepDrop::className(), ['options' => ['id' => 'location_region_id', 'placeholder' => Yii::t('jlorente/location', '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(["/{$this->module->id}/region/list"]), 'depends' => ['location_country_id']]]);
 }