/** * * @return 所有office的一个id为KEY,office_id值为VALUE的一个一维数组 * */ public static function AllOffice() { $officeSql = 'select id_office,office_id from ' . Office::tableName() . ' limit 1000'; $res = static::getDb()->createCommand($officeSql)->queryAll(); $result = ArrayHelper::map($res, 'id_office', 'office_id'); return $result; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Office::find(); if (!isset($params['sort'])) { $query->orderBy(['id_office' => SORT_DESC]); } $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_office' => $this->id_office, 'id_institution' => $this->id_institution, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'office_id', $this->office_id])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'zip', $this->zip])->andFilterWhere(['like', 'phone', $this->phone]); return $dataProvider; }
public function getOffice() { return $this->hasOne(Office::className(), ['id_office' => 'id_office']); }
/** * Finds the Office model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Office the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Office::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo $form->field($model, 'id_institution')->label('Institution')->dropDownList(ArrayHelper::map(Institution::find()->all(), 'id_institution', function ($item) { return $item['institution_id'] . '-' . $item['institution_name']; }), ['prompt' => 'Select...']); ?> <div class="form-group field-advisorgroup-id_advisor required"> <label class="col-sm-3 control-label form-label" for="id_advisor">Id Group</label> <div class="col-sm-8"> <?php echo Select2::widget(['name' => 'id_group', 'value' => ArrayHelper::map($model->groups, 'id_group', 'id_group'), 'data' => ArrayHelper::map(Group::find()->all(), 'id_group', 'group_id'), 'options' => ['placeholder' => 'Select ...', 'multiple' => true], 'pluginOptions' => ['maximumInputLength' => 10, 'ajax' => ['url' => Url::to(['group/get-all-group-list']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }')]]]); ?> </div> </div> <?php echo $form->field($model, 'id_office')->dropDownList(ArrayHelper::map(Office::find()->all(), 'id_office', 'office_id'), ['prompt' => 'Select...']); ?> <?php if (empty($userModel->new_email)) { ?> <?php echo $form->field($userModel, 'email')->textInput(['maxlength' => true]); ?> <?php } else { ?> <?php echo $form->field($userModel, 'new_email')->textInput(['maxlength' => true])->label('Email'); ?> <?php
<?php // $form->field($model, 'countries')->dropDownList( // ArrayHelper::map(Countries::find()->all(), 'country_code', 'country_name') // ) ?> <?php echo $form->field($model, 'countries')->widget(Select2::classname(), ['data' => ArrayHelper::map(Office::find()->all(), 'country_code', 'country_name'), 'options' => ['placeholder' => 'Select Country'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'office')->widget(Select2::classname(), ['data' => ArrayHelper::map(Office::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select office'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'age')->textInput(); ?> <?php echo $form->field($model, 'address')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'zip_code')->textInput(['maxlength' => true]); ?>
?> </button> <h3 class="modal-title" id="myModalLabel"> <?php echo Yii::t('app', 'Add Advisor'); ?> </h3> </div> <div class="modal-body"> <div class="panel-body"> <input type="hidden" name="id" value="<?php echo $id; ?> "> <?php echo $form->field($model, 'id_office')->dropDownList(ArrayHelper::merge(['' => 'Select...'], ArrayHelper::map(Office::find()->all(), 'id_office', 'office_id')))->label('Office'); ?> <?php echo $form->field($model, 'id_institution')->dropDownList(ArrayHelper::merge(['' => 'Select...'], ArrayHelper::map(Institution::find()->all(), 'id_institution', 'institution_name')))->label('Institution'); ?> <?php echo $form->field($model, 'advisor_id')->textInput(['maxlength' => true]); ?> <?php echo $form->field($user, 'first_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($user, 'mid_name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($user, 'last_name')->textInput(['maxlength' => true]);