コード例 #1
0
 /**
  * Рендерит html регионов для dropdown
  * @param int $id идентификатор страны
  * @throws \yii\base\ExitException
  */
 public function actionRegions($id)
 {
     $all = Region::find()->published()->where(["country_id" => $id])->orderBy(["title" => SORT_ASC])->all();
     $o = ["prompt" => ""];
     echo Html::renderSelectOptions(null, ArrayHelper::map($all, "id", "title"), $o);
     Yii::$app->end();
 }
コード例 #2
0
ファイル: RegionSearch.php プロジェクト: fernandrez/ipcbsas
 /**
  * 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()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'pais_id' => $this->pais_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'pais_cd', $this->pais_cd])->andFilterWhere(['like', 'region_cd', $this->region_cd])->andFilterWhere(['like', 'nombre', $this->nombre])->andFilterWhere(['like', 'status', $this->status]);
     return $dataProvider;
 }
コード例 #3
0
 public function actionGetCiudadesRegion($region_id, $empty = true)
 {
     if ($empty) {
         $options = ['' => 'Escoge ciudad'];
     }
     $ciudades = Region::find()->where(['id' => $region_id])->one()->ciudads;
     $ciudades = ArrayHelper::map($ciudades, 'id', 'nombre');
     asort($ciudades);
     $options += $ciudades;
     echo Html::renderSelectOptions('', $options);
 }