public function search($params) { $query = CategoryModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_category' => $this->id_category, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'cd_category', $this->cd_category])->andFilterWhere(['like', 'nm_category', $this->nm_category])->andFilterWhere(['like', 'create_date', $this->create_date])->andFilterWhere(['like', 'update_date', $this->update_date]); return $dataProvider; }
/** * Finds the Category model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Category the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Category::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<div class="panel panel-primary"> <div class="panel-heading"> Product </div> <div class="panel-body"> <?php echo $form->field($model, 'cd_product')->textInput(['maxlength' => 13, 'style' => 'width:160px;']); ?> <?php echo $form->field($model, 'nm_product')->textInput(['maxlength' => 64]); ?> <?php echo $form->field($model, 'id_category')->dropDownList(ArrayHelper::map(Category::find()->all(), 'id_category', 'nm_category'), ['style' => 'width:200px;']); ?> <?php echo $form->field($model, 'id_group')->dropDownList(ArrayHelper::map(ProductGroup::find()->all(), 'id_group', 'nm_group'), ['style' => 'width:200px;']); ?> </div> </div> </div> <style> .tab-content { border: 1px #e0e0e0 solid;
/** * @return \yii\db\ActiveQuery */ public function getIdCategory() { return $this->hasOne(Category::className(), ['id_category' => 'id_category']); }