/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = EventType::find(); $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' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
use yii\helpers\Html; use yii\widgets\ActiveForm; use yii\widgets\ListView; ?> <div class="page-heading"> <div class="container"> <h2>Тренинги</h2> <div class="gap"></div> <div class="col-md-12"> <div class="row"> <?php $form = ActiveForm::begin(['action' => ['index'], 'method' => 'get', 'id' => 'event-search-form']); ?> <div class="col-md-3"> <?php echo $form->field($searchModel, 'type')->dropDownList(ArrayHelper::map(EventType::find()->all(), 'id', 'name'), ['prompt' => 'Любой тип тренинга'])->label(false); ?> </div> <div class="col-md-3"> <?php echo $form->field($searchModel, 'city_id')->dropDownList(ArrayHelper::map(City::find()->where(['region_id' => '10373'])->orderBy('name')->all(), 'city_id', 'name'), ['prompt' => 'В любом городе'])->label(false); ?> </div> <div class="col-md-6"> <!--<button type="submit" class="btn-style">Искать</button>--> <?php echo Html::submitButton('Искать', ['class' => 'btn-style']); ?> </div> <?php ActiveForm::end();
<div class="col-md-12"> <?php echo $form->field($imagesModel, 'image_file')->fileInput()->label('Выберите фото'); ?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'type')->dropDownList(ArrayHelper::map(EventType::find()->all(), 'id', 'name'), ['prompt' => 'Укажите тип тренинга']); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'date')->textInput(['id' => 'eventDateInput']); ?> </div> <div class="col-md-4"> <?php echo $form->field($model, 'duration')->textInput(['maxlength' => true]); ?> </div> <div class="col-md-4"> <?php