/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Perk::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]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
<div class="worker-form"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php echo $form->field($model, 'name')->textarea(['rows' => 6]); ?> <?php echo $form->field($model, 'dep_id')->dropDownList(ArrayHelper::map(Dep::find()->all(), 'id', 'name')); ?> <?php echo $form->field($model, 'perks_list')->dropDownList(ArrayHelper::map(Perk::find()->all(), 'id', 'name'), ['multiple' => true]); ?> <?php echo $form->field($model, 'img')->fileInput(); ?> <?php echo $model->img ? Html::img('/uploads/' . $model->img, ['width' => 100, 'height' => 100]) : null; ?> <div class="form-group"> <?php