/** * @return array */ public function getVenueOptions() { $raw = Venue::find()->orderBy('VenueType_id')->all(); $arr = array(); foreach ($raw as $row) { $venueType = \app\models\VenueType::getVenueTypeById($row['VenueType_id']); $arr[$row['id']] = $venueType . ' - ' . $row['name']; } return $arr; }
public function getVenueTypeById($id) { $raw = VenueType::findOne($id); return $raw['name']; }
/** * Finds the VenueType model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return VenueType the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = VenueType::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'location')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'map')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'floorPlan')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'VenueType_id')->dropDownList(\app\models\VenueType::getVenueTypeOptions()); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div>
/** * @return \yii\db\ActiveQuery */ public function getVenueType() { return $this->hasOne(VenueType::className(), ['id' => 'VenueType_id']); }