public function getSports()
 {
     return $this->hasOne(Sports::className(), ['id' => 'sports_id']);
 }
<div class="homepage-main">
    <div class="container">
        <div class="col-menu">
            <?php 
require dirname(__DIR__) . '/default/nav_menu_sidebar.php';
?>
        </div>
        <div class="col-main">
            <div class="content-box">
                <h3>新增场地类型</h3>
                <div class="mc">
                    <div class="mc-body">
                        <?php 
$form = ActiveForm::begin(['id' => 'fc-add-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => '<div class="col-md-2">{label}</div><div class="col-md-3">{input}</div>', 'labelOptions' => ['class' => 'control-label']]]);
$sports = Sports::listAll();
?>
                        <?php 
echo $form->field($model, 'name')->label('场地类型名字')->hint('方便场地集中管理');
?>

                        <?php 
echo $form->field($model, 'sports_id')->label('运动类型')->dropDownList($sports);
?>

                        <?php 
echo $form->field($model, 'quantity')->label('场地数量');
?>

                        <div class="form-group">
                            <div class="col-md-2">
 /**
  * 加载文章发布页面
  */
 public function actionAdd()
 {
     $model = new ArticleWriteForm();
     $sports = Sports::listAll();
     return $this->render('add', ['model' => $model, 'sports' => $sports]);
 }
예제 #4
0
 public function getAllSports()
 {
     $allSports = Sports::listAll();
     $returnSports = [];
     foreach ($allSports as $sport) {
         $returnSports[$sport['id']] = $sport['name'];
     }
     return $returnSports;
 }
예제 #5
0
 public function getSports()
 {
     return $this->hasMany(Sports::className(), ['id' => 'sports_id'])->via('gymSports')->where(['status' => Sports::STATUS_ACTIVE])->orderBy('id');
 }