public function search($params) { $query = ProductGroupModel::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id_group' => $this->id_group, 'create_by' => $this->create_by, 'update_by' => $this->update_by]); $query->andFilterWhere(['like', 'cd_group', $this->cd_group])->andFilterWhere(['like', 'nm_group', $this->nm_group])->andFilterWhere(['like', 'create_at', $this->create_at])->andFilterWhere(['like', 'update_at', $this->update_at]); return $dataProvider; }
/** * Finds the ProductGroup model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return ProductGroup the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = ProductGroup::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<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 class="panel-footer"> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> </div> </div> </div> <style> .tab-content { border: 1px #e0e0e0 solid;
/** * @return \yii\db\ActiveQuery */ public function getIdGroup() { return $this->hasOne(ProductGroup::className(), ['id_group' => 'id_group']); }