public function actionAdd() { $provinces = Area::findProvinces(); $provinceNames[] = "请选择省份"; foreach ($provinces as $province) { $provinceNames[$province['id']] = $province['name']; } $model = new GymInfo(); $test = \Yii::$app->request->post(); if ($test) { $model->attributes = $test['GymInfo']; $model->open_time = "[" . $_POST['begin_time'] . ',' . $_POST['end_time'] . ']'; echo $test['province']; $GymUser_id = \Yii::$app->getUser()->id; $manager = GymAdmin::findIdentity($GymUser_id); $model->manager = $manager['username']; $model->province = $test['province']; $model->city = $test['city']; $model->county = $test['county']; $model->wechat = $test['GymInfo']['wechat']; $model->sports = $test['GymInfo']['sports']; $model->saveGymInfo($GymUser_id); $model->field = $model->getFiled(); $model->coach = $model->getCoach(); $gym_id = $model->gym_id; return $this->render('index', ['model' => $model, 'gym_id' => $gym_id]); } else { return $this->render('gym_add', ['model' => $model, 'provinces' => $provinceNames]); } }
public function actionProvinces() { $provinces = Area::findProvinces(); foreach ($provinces as $province) { echo '<option value="' . $province['id'] . '">' . $province['name'] . '</option>' . PHP_EOL; } }