/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Categories::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([ 'is_active' => $this->is_active, ]); $query->andFilterWhere(['like', 'name', $this->name]) ->andFilterWhere(['like', 'description', $this->description]) ->andFilterWhere(['like', 'create_date', $this->create_date]); return $dataProvider; }
public function CategoryList(){ if($this->_categoryList == null){ $this->_categoryList = ArrayHelper::map(Categories::find()->asArray()->all(),'id','name'); } return $this->_categoryList; }
//'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> <?php ActiveForm::end(); ?> <?php Pjax::end();?>