/** * @return array */ public static function getKindsOfSport() { $result = []; foreach (Sport::find()->asArray()->all() as $item) { $result[$item['id']] = $item['name']; } return $result; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Sport::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['or', ['like', 'name', $this->name], ['like', 'url_key', $this->url_key]]); return $dataProvider; }
/* @var $model common\models\Competition */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="competition-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'sport_id')->dropDownList(ArrayHelper::map(Sport::find()->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'events_set_id')->dropDownList(ArrayHelper::map(EventsSet::find()->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'date_start')->widget(DatePicker::classname(), ['dateFormat' => 'yyyy-MM-dd']); ?> <?php echo $form->field($model, 'date_finish')->widget(DatePicker::classname(), ['dateFormat' => 'yyyy-MM-dd']); ?> <?php