Exemplo n.º 1
0
 /**
  * 修改数据
  */
 public function actionUpdate($id)
 {
     if ($this->isPost) {
         $params = $this->request->post('City');
         $res = $this->client->put('/city/{id}', $params, ['id' => $id]);
         if ($this->client->isValid || true) {
             return '';
         } else {
             throw new UserError($this->client->errors);
         }
     } else {
         $res = $this->client->get('/city/{id}', ['id' => $id]);
         $model = new City();
         $model->isNewRecord = false;
         $model->setAttributes($res, false);
         return $this->render('city_update', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 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>";
     }
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
 /**
  * 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;
 }
Exemplo n.º 6
0
Arquivo: _form.php Projeto: kkkiii/gnw
?>

    <?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]);
Exemplo n.º 7
0
Arquivo: Maker.php Projeto: kkkiii/gnw
 public function trans_city($id)
 {
     $city = City::find()->where('id =' . $id)->one();
     return $city->cityname;
 }
Exemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCity()
 {
     return $this->hasOne(City::className(), ['id' => 'city_id']);
 }
Exemplo n.º 9
0
 /**
  * Finds the City model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return City the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = City::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemplo n.º 10
0
Arquivo: Prov.php Projeto: kkkiii/gnw
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCities()
 {
     return $this->hasMany(City::className(), ['prov_id' => 'id']);
 }