public function actionLists($id) { $countCitys = City::find()->where(['prov_id' => $id])->count(); $cities = City::find()->where(['prov_id' => $id])->all(); if ($countCitys > 0) { foreach ($cities as $city) { echo "<option value='" . $city->id . "'>" . $city->cityname . "</option>"; } } else { echo "<option> - </option>"; } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = City::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, 'Population' => $this->Population]); $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'CountryCode', $this->CountryCode])->andFilterWhere(['like', 'District', $this->District]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = City::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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = City::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, 'region_id' => $this->region_id, 'status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'country_code', $this->country_code]); return $dataProvider; }
?> <?php echo $form->field($model, 'gender')->dropDownList(['女' => '女', '男' => '男']); ?> </div> <div class="form-inline"> <?php echo $form->field($model, 'prov')->dropDownList(ArrayHelper::map(Prov::find()->all(), 'id', 'provname'), ['prompt' => '选个省直/辖市', 'onchange' => ' $.post( "index.php?r=maker/lists&id=' . '"+$(this).val(), function( data ) { $( "select#maker-city" ).html( data ); });']); ?> <?php echo $form->field($model, 'city')->dropDownList(ArrayHelper::map(City::find()->all(), 'id', 'cityname'), []); ?> </div> <?php echo $form->field($model, 'begoodat')->checkboxlist(ArrayHelper::map(Begoodatprof::find()->all(), 'id', 'begoodat'), [0, 2]); ?> <?php echo $form->field($model, 'unicres')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'simpcv')->textarea(['maxlength' => true]);
public function trans_city($id) { $city = City::find()->where('id =' . $id)->one(); return $city->cityname; }