/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Cities::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['idcities' => $this->idcities, 'idstates' => $this->idstates]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'longitude', $this->longitude])->andFilterWhere(['like', 'latitude', $this->latitude])->andFilterWhere(['like', 'wikilink', $this->wikilink]); return $dataProvider; }
public function actionIndex() { // return "ok"; $params = yii::$app->getRequest()->getQueryParams(); if (empty($params['province_id']) && empty($params['province_id'])) { $query = Provinces::find(); } if (!empty($params['province_id'])) { $query = Cities::find()->where(['province_id' => $params['province_id']]); } if (!empty($params['city_id'])) { $query = Districts::find()->where(['city_id' => $params['city_id']]); } return new yii\data\ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 50)]); }
public function getCity() { return $this->hasOne(Cities::className(), ['id' => 'city_id']); }
<label>State</label> <?php if (!empty($addre->state_id)) { $state = ArrayHelper::map(\common\models\States::findAll(['id' => $address->state_id]), 'id', 'name'); } else { $state = []; } // print_r($state);die; echo $form->field($address, 'state_id')->dropDownList($state, ['prompt' => 'Select State', 'class' => 'singleSelectBox', 'data-tags' => true, 'onChange' => 'signup_obj.statechange("' . Url::toRoute(['site/city']) . '")'])->label(false); ?> </div> <div class="col col3"> <label>City</label> <?php if (!empty($address->city_id)) { $city = ArrayHelper::map(\common\models\Cities::findAll(['id' => $address->city_id]), 'id', 'name'); } else { $city = []; } echo $form->field($address, 'city_id')->dropDownList($city, ['prompt' => 'Select City', 'class' => 'singleSelectBox', 'data-tags' => true])->label(false); ?> </div> </div> <div class="col-3 clearfix"> <div class="col col1"> <label>Landmark</label> <?php echo $form->field($address, 'landmark')->textInput(['class' => 'form-control', 'placeholder' => 'Landmark'])->label(false); ?> </div> <div class="col col2">
/** * @return \yii\db\ActiveQuery */ public function getCities() { return $this->hasMany(Cities::className(), ['idstates' => 'idstates']); }
/** * @return \yii\db\ActiveQuery */ public function getCities() { return $this->hasMany(Cities::className(), ['GeoZoneId' => 'GeoZoneId']); }
public function actionCity() { $stateId = $_POST['state_id']; $citydata = \common\models\Cities::findAll(['stateID' => $stateId]); $citylist = "<option value=''>Select City</option>"; if (count($citydata) > 0) { foreach ($citydata as $city) { $citylist .= "<option value='" . $city->id . "'>" . $city->name . "</option>"; } } else { $citylist = "<option>-</option>"; } \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['citylist' => $citylist, 'code' => 100]; }
/** * @return \yii\db\ActiveQuery */ public function getIdcities0() { return $this->hasOne(Cities::className(), ['idcities' => 'idcities']); }
public function actionCity() { $stateId = $_POST['state_id']; $citydata = \common\models\Cities::find()->where(['stateID' => $stateId])->orderBy(['name' => SORT_ASC])->all(); //return "asdasd"; //$citydata = CHtml::listData($citydata, 'id', 'name'); $citylist = "<option value=''>Select City</option>"; if (count($citydata) > 0) { foreach ($citydata as $city) { $citylist .= "<option value='" . $city->id . "'>" . $city->name . "</option>"; } } else { $citylist = "<option>-</option>"; } \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ['citylist' => $citylist, 'code' => 100]; }
/** * Finds the Cities model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Cities the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Cities::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }