/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Companyagency::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, 'companyAgencyCreate' => $this->companyAgencyCreate, 'companyAgencyUpdate' => $this->companyAgencyUpdate]); $query->andFilterWhere(['like', 'companyAgencyCode', $this->companyAgencyCode])->andFilterWhere(['like', 'companyAgencyName', $this->companyAgencyName])->andFilterWhere(['like', 'companyAgencyDesc', $this->companyAgencyDesc]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getCompanyAgency() { return $this->hasOne(Companyagency::className(), ['id' => 'companyAgency_id']); }
/** * Finds the Companyagency model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Companyagency the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Companyagency::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
<?php echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\common\models\Category::find()->all(), 'id', 'categoryName'), ['prompt' => 'Category']); ?> <?php echo $form->field($model, 'type_id')->dropDownList(ArrayHelper::map(\common\models\Type::find()->all(), 'id', 'typeName'), ['prompt' => 'Type']); ?> <?php echo $form->field($model, 'priority_id')->dropDownList(ArrayHelper::map(\common\models\Priority::find()->all(), 'id', 'priorityName'), ['prompt' => 'Priority']); ?> <?php echo $form->field($model, 'companyAgency_id')->dropDownList(ArrayHelper::map(\common\models\Companyagency::find()->all(), 'id', 'companyAgencyName'), ['prompt' => 'Company Agency']); ?> <?php echo $form->field($model, 'section_id')->dropDownList(ArrayHelper::map(\common\models\Section::find()->all(), 'id', 'sectionName'), ['prompt' => 'Section']); ?> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?>