/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Brands::find(); $dataProvider = new ActiveDataProvider([ 'query' => $query, ]); $this->load($params); $dataProvider->pagination->pageSize=$this->pageSize; 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, 'create_date' => $this->create_date, 'update_date' => $this->update_date, 'is_active' => $this->is_active, ]); $query->andFilterWhere(['like', 'name', $this->name]) ->andFilterWhere(['like', 'description', $this->description]) ->andFilterWhere(['like', 'image', $this->image]); return $dataProvider; }
<?php $form = ActiveForm::begin([ 'id' => 'create-brand', //'action' => Url::to(['brand/create']), 'options' => [ 'data-pjax' => 1, 'enctype' => 'multipart/form-data' ], 'enableClientValidation' => false ]); ?> <?= Html::hiddenInput('id', $model->id);?> <?= $form->field($model, 'name')->textInput() ?> <?= $form->field($model, 'brand_id')->dropDownList(ArrayHelper::map(Brands::find()->asArray()->all(),'id' ,'name')) ?> <?= $form->field($model, 'cat_id')->dropDownList(ArrayHelper::map(Categories::find()->asArray()->all(),'id' ,'name')) ?> <?= $form->field($model, 'prize')->textInput() ?> <?= $form->field($model, 'image')->fileInput() ?> <?= $form->field($model, 'condition')->textarea(['row' => 2]) ?> <?= $form->field($model, 'extra_cond')->textarea(['row' => 2]) ?> <div class="form-group"> <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?> </div>